[issue18588] timeit examples should be consistent
New submission from Clay McClure: The timeit module documentation includes examples of command-line and programmatic invocation, but the results between the two sets of examples don't agree. This patch brings the results into agreement with each other. ---------- keywords: +patch Added file: http://bugs.python.org/file31076/18588.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18588> _______________________________________
Ezio Melotti added the comment: IIRC those were the actual values I got. I think I investigated why they were different, but right now I don't remember if I found out why. ---------- assignee: docs@python -> ezio.melotti nosy: +ezio.melotti versions: -Python 2.6, Python 3.1, Python 3.2, Python 3.3 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18588> _______________________________________
Serhiy Storchaka added the comment: In command-line invocation the gc is disabled. And timit.repeat() is used instead of timit.timit(). ---------- nosy: +serhiy.storchaka _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18588> _______________________________________
Clay McClure added the comment: There's a 68% difference in running time between the command-line and programmatic invocations shown in the current documentation, and a 1% difference between the runtimes shown in the patch. I can't speak for why that is the case, but I did find it somewhat confusing when trying to interpret the timeit documentation. Being a somewhat pedantic and trivial patch, I'm fine if you want to close it wontfix. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18588> _______________________________________
Mark Lawrence added the comment: @Steven you're into timeit, do you have anything to add here? ---------- nosy: +BreamoreBoy, steven.daprano _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18588> _______________________________________
Raymond Hettinger added the comment:
I did find it somewhat confusing when trying to interpret the timeit documentation.
Perhaps that is a good thing. Making good, repeatable, meaningful timings where you have a clear interpretation of the results is non-trivial, learned skill. Cross-checking results and explaining differences are fundamental skills. There is really no reason the docs should try to make it look easier that it really is (running the tool is easy, but interpreting results sometimes isn't).
Being a somewhat pedantic and trivial patch, I'm fine if you want to close it wontfix.
That is reasonable. I don't that this has caused any actual impediment to learning how to use timeit. The docs have been somewhat successful in that regard. ---------- nosy: +rhettinger _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18588> _______________________________________
Ezio Melotti added the comment: I tried to run those timings again and the values I got from the terminal are close to the ones I got from the interactive interpreter. I'm not sure why when I wrote those examples I got such different values. It would be fine with me to update them and avoid confusion.
In command-line invocation the gc is disabled. And timit.repeat() is used instead of timit.timit().
Looking at the current code it seems to me that the command-line uses timeit.repeat(), that repeat calls timeit.timeit(), and that timeit.timeit() disables the gc. Maybe back then it was different; that would explain why I got different results. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18588> _______________________________________
Roundup Robot added the comment: New changeset c39457a07caa by Ezio Melotti in branch '3.4': #18588: update the timeit examples to be consistent. http://hg.python.org/cpython/rev/c39457a07caa New changeset 45b208ae9eab by Ezio Melotti in branch 'default': #18588: merge with 3.4. http://hg.python.org/cpython/rev/45b208ae9eab ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18588> _______________________________________
Ezio Melotti added the comment: Examples updated, thanks for the report! ---------- resolution: -> fixed stage: -> resolved status: open -> closed versions: -Python 2.7 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18588> _______________________________________
participants (6)
-
Clay McClure
-
Ezio Melotti
-
Mark Lawrence
-
Raymond Hettinger
-
Roundup Robot
-
Serhiy Storchaka