[Python-checkins] cpython (3.4): #15183: clarify timeit documentation to say that setup statement isn't timed

andrew.kuchling python-checkins at python.org
Wed Apr 22 01:46:59 CEST 2015


https://hg.python.org/cpython/rev/e0e3d2ec56b6
changeset: 95756:e0e3d2ec56b6
branch: 3.4
parent: 95753:a480f470c469
user: Andrew Kuchling <amk at amk.ca>
date: Tue Apr 21 19:43:33 2015 -0400
summary:
 #15183: clarify timeit documentation to say that setup statement isn't timed
files:
 Doc/library/timeit.rst | 2 ++
 Lib/timeit.py | 3 ++-
 2 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst
--- a/Doc/library/timeit.rst
+++ b/Doc/library/timeit.rst
@@ -94,6 +94,8 @@
 method. The :meth:`.repeat` method is a convenience to call :meth:`.timeit`
 multiple times and return a list of results.
 
+ The execution time of *setup* is excluded from the overall timed execution run.
+
 The *stmt* and *setup* parameters can also take objects that are callable
 without arguments. This will embed calls to them in a timer function that
 will then be executed by :meth:`.timeit`. Note that the timing overhead is a
diff --git a/Lib/timeit.py b/Lib/timeit.py
--- a/Lib/timeit.py
+++ b/Lib/timeit.py
@@ -14,7 +14,8 @@
 Options:
 -n/--number N: how many times to execute 'statement' (default: see below)
 -r/--repeat N: how many times to repeat the timer (default 3)
- -s/--setup S: statement to be executed once initially (default 'pass')
+ -s/--setup S: statement to be executed once initially (default 'pass').
+ Execution time of this setup statement is NOT timed.
 -p/--process: use time.process_time() (default is time.perf_counter())
 -t/--time: use time.time() (deprecated)
 -c/--clock: use time.clock() (deprecated)
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /