◐ Shell
clean mode source ↗

Message 259502 - Python tracker

Antoine, yeah, it's probably turbo boost related.  There is no easy way to turn it off on mac os x, though.  I hope Victor's patch to perf.py will help to mitigate this. 

Victor, Marc-Andre,

Updated results of nano-bench (best of 10):

-m timeit -s "loops=tuple(range(100))" "sum([x * x * 1 for x in loops])"
2.7  8.5     3.5  10.1     3.6  8.91

-m timeit -s "loops=tuple(range(100))" "sum([x + x + 1 for x in loops])"
2.7  7.27    3.5  8.2      3.6  7.13

-m timeit -s "loops=tuple(range(100))" "sum([x - x - 1 for x in loops])"
2.7  7.01    3.5  8.1      3.6  6.95

Antoine, Serhiy, I'll upload a new patch soon.  Probably Serhiy's idea of using a switch statement will make it slightly faster.  I'll also add a fast path for integer division.