[Python-checkins] bpo-28240: timeit: Update repeat() doc (GH-7419)

Victor Stinner webhook-mailer at python.org
Wed Jun 6 11:55:21 EDT 2018


https://github.com/python/cpython/commit/3ef769fcd378a7f1cda19c0dfec2e79613d79e48
commit: 3ef769fcd378a7f1cda19c0dfec2e79613d79e48
branch: master
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2018年06月06日T17:55:18+02:00
summary:
bpo-28240: timeit: Update repeat() doc (GH-7419)
Document that the default value of repeat changed from 3 to 5 in
Python 3.7.
files:
M Doc/library/timeit.rst
M Lib/timeit.py
diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst
index d922fd6f32e2..93ca940ef5bd 100644
--- a/Doc/library/timeit.rst
+++ b/Doc/library/timeit.rst
@@ -69,7 +69,7 @@ The module defines three convenience functions and a public class:
 The optional *globals* parameter was added.
 
 
-.. function:: repeat(stmt='pass', setup='pass', timer=<default timer>, repeat=3, number=1000000, globals=None)
+.. function:: repeat(stmt='pass', setup='pass', timer=<default timer>, repeat=5, number=1000000, globals=None)
 
 Create a :class:`Timer` instance with the given statement, *setup* code and
 *timer* function and run its :meth:`.repeat` method with the given *repeat*
@@ -79,6 +79,9 @@ The module defines three convenience functions and a public class:
 .. versionchanged:: 3.5
 The optional *globals* parameter was added.
 
+ .. versionchanged:: 3.7
+ Default value of *repeat* changed from 3 to 5.
+
 .. function:: default_timer()
 
 The default timer, which is always :func:`time.perf_counter`.
@@ -150,7 +153,7 @@ The module defines three convenience functions and a public class:
 .. versionadded:: 3.6
 
 
- .. method:: Timer.repeat(repeat=3, number=1000000)
+ .. method:: Timer.repeat(repeat=5, number=1000000)
 
 Call :meth:`.timeit` a few times.
 
@@ -171,6 +174,9 @@ The module defines three convenience functions and a public class:
 should be interested in. After that, you should look at the entire
 vector and apply common sense rather than statistics.
 
+ .. versionchanged:: 3.7
+ Default value of *repeat* changed from 3 to 5.
+
 
 .. method:: Timer.print_exc(file=None)
 
@@ -208,7 +214,7 @@ Where the following options are understood:
 
 .. cmdoption:: -r N, --repeat=N
 
- how many times to repeat the timer (default 3)
+ how many times to repeat the timer (default 5)
 
 .. cmdoption:: -s S, --setup=S
 
@@ -246,7 +252,7 @@ successive powers of 10 until the total time is at least 0.2 seconds.
 :func:`default_timer` measurements can be affected by other programs running on
 the same machine, so the best thing to do when accurate timing is necessary is
 to repeat the timing a few times and use the best time. The :option:`-r`
-option is good for this; the default of 3 repetitions is probably enough in
+option is good for this; the default of 5 repetitions is probably enough in
 most cases. You can use :func:`time.process_time` to measure CPU time.
 
 .. note::
diff --git a/Lib/timeit.py b/Lib/timeit.py
index 418166d7918e..c0362bcc5f3e 100755
--- a/Lib/timeit.py
+++ b/Lib/timeit.py
@@ -13,7 +13,7 @@
 
 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)
+ -r/--repeat N: how many times to repeat the timer (default 5)
 -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())
@@ -184,7 +184,7 @@ def repeat(self, repeat=default_repeat, number=default_number):
 
 This is a convenience function that calls the timeit()
 repeatedly, returning a list of results. The first argument
- specifies how many times to call timeit(), defaulting to 3;
+ specifies how many times to call timeit(), defaulting to 5;
 the second argument specifies the timer argument, defaulting
 to one million.
 


More information about the Python-checkins mailing list

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