4 ms·
That doesn't tell you about the speed of the code though. $> python -m timeit "1 <= 4 <= 5" 10000000 loops, best of 3: 0.0877 usec per loop $>
by squeaky-clean 11y ago
That doesn't tell you about the speed of the code though.
$> python -m timeit "1 <= 4 <= 5"
10000000 loops, best of 3: 0.0877 usec per loop
$> python -m timeit "4 in range(1,5)"
1000000 loops, best of 3: 0.413 usec per loop
$> python -m timeit "4 in (1,2,3,4,5)"
10000000 loops, best of 3: 0.0776 usec per loop
Tested in python 3.5.0, Even with the improvements to the range function, the comparison is almost 5x faster.