[issue32039] timeit documentation should describe caveats

2017-11-23 Thread Serhiy Storchaka
Serhiy Storchaka 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(1));random.shuffle(a)' 'a.sort();a[-1]' Here the list is sorted at first iteration, and all following iteration

[issue32039] timeit documentation should describe caveats

2017-11-15 Thread STINNER Victor
STINNER Victor added the comment: Barry: "... possibly point to both cProfile and the 3rd party perf package as alternative ways to gather performance information." FYI the timeit module of PyPy now emits a warning and points to the perf module: http://perf.readthedocs.io/ -- __

[issue32039] timeit documentation should describe caveats

2017-11-15 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- nosy: +haypo ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue32039] timeit documentation should describe caveats

2017-11-15 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: On Nov 15, 2017, at 17:00, Serhiy Storchaka wrote: > > +1 to all said by Raymond. But this is rather the matter of a special article > or blog post than a note in the documentation. Maybe a HOWTO on performance testing and analysis? We already have one on

[issue32039] timeit documentation should describe caveats

2017-11-15 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: +1 to all said by Raymond. But this is rather the matter of a special article or blog post than a note in the documentation. Other example of caching is regular expressions. Mistakes: python3 -m timeit -s "it = iter(range(10))" "next(it)" python3

[issue32039] timeit documentation should describe caveats

2017-11-15 Thread Raymond Hettinger
Raymond Hettinger added the comment: Other caveats: * The tight, repeated loops tend to have perfect branch prediction rates and 100% L1 cache hit rates that are rarely present in real code. There should be links to why this matters: - https://stackoverflow.com/questions/11227809 -

[issue32039] timeit documentation should describe caveats

2017-11-15 Thread Barry A. Warsaw
New submission from Barry A. Warsaw : timeit is cool, but it's not appropriate for all performance testing. For example, since it uses only a single Python process, anything that's cached is not a good candidate for timeit profiling. The classic example is timing imports. E.g. these are not