[issue32039] timeit documentation should describe caveats
Serhiy Storchaka
report at bugs.python.org
Thu Nov 23 08:12:53 EST 2017
Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:
Yet one mistake: https://stackoverflow.com/questions/35014951/why-is-max-slower-than-sort
$ python3 -m timeit -s 'import random;a=list(range(10000));random.shuffle(a)' 'a.sort();a[-1]'
Here the list is sorted at first iteration, and all following iterations measure the speed of sorting a sorted list.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32039>
_______________________________________
More information about the Python-bugs-list
mailing list