If I understand your question correctly, this code is for you:
Using generators comprehension:
pred = i%2 is 0
forced_values = [5, 7]
list((i for i in range(0, 10) if pred or i in forced_values))
# output: [0, 2, 4, 5, 6, 7, 8]
or equivalently:
sorted(list(range(0, 10, 2)) + forced_values)
Comparison of execution times:
Benchmark:
n = 10000000 # size of range values
m = 10000000 # size of forced_value list
1. Solution with generators comprehension:
%%timeit
list((i for i in range(0, n) if i%2 is 0 or i in range(0, m)))
# 3.47 s ± 265 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
2. Solution with sorting:
%%timeit
sorted(list(range(0, n, 2)) + list(range(0, m)))
# 1.59 s ± 11.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
or with unordered list, if the order is not important:
%%timeit
list(range(0, n, 2)) + list(range(0, m))
# 1.03 s ± 109 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
3. Solution proposed by @blhsing with more_itertools package, and specifically collate function:
%%timeit
l = []
for i in collate(range(0, n, 2), range(0, m)):
l.append(i)
# 6.89 s ± 886 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
The best solution, even on very large lists, seems to be the second one that is 2 to 4 times faster than the other proposed solutions.