Why is this for a cycle with an if condition in the first case more than 2 times faster than the second case with a conditional expression of the generator?
%%timeit for i in range(100000): if i < 10000: continue pass
on 100 loops, best of 3: 2.85 ms per cycle, using the generator expression:
%%timeit for i in (i for i in range(100000) if i >= 10000): pass
100 cycles, best of 3: 6.03 ms per cycle
source share