STINNER Victor added the comment:

Serhiy Storchaka:
>> * autorange: start with 1 loop instead of 10 for slow benchmarks like 
>> time.sleep(1)
> This is good if you run relatively slow benchmark, but it makes the result 
> less reliable. You always can specify -n1, but on your own risk.

Sorry, I don't understand how running 1 iteration instead of 10 makes the 
benchmark less reliable. IMO the reliability is more impacted by the number of 
repeatitions (-r). I changed the default from 3 to 5 repetitions, so timeit 
should be *more* reliable in Python 3.7 than 3.6.

> Even "pass" takes at least 0.02 usec on my computer. What you want to measure 
> that takes < 1 ns? I think timeit is just wrong tool for this.

It's just a matter of formatting. IMO clocks have a precision good enough to 
display nanoseconds when the benchmark uses many iterations (which is the case 
by default since autorange uses a minimum of 200 ms per benchmark).


$ python3.6 -m timeit 'pass'
100000000 loops, best of 3: 0.0339 usec per loop


$ python3.7 -m timeit 'pass'
10000000 loops, best of 5: 33.9 nsec per loop

IMO "33.9" is more readable than "0.0339".


Python tracker <>
Python-bugs-list mailing list

Reply via email to