Skip to content

Commit 3ef769f

Browse files
authored
bpo-28240: timeit: Update repeat() doc (GH-7419)
Document that the default value of repeat changed from 3 to 5 in Python 3.7.
1 parent 492d642 commit 3ef769f

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

Doc/library/timeit.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ The module defines three convenience functions and a public class:
6969
The optional *globals* parameter was added.
7070

7171

72-
.. function:: repeat(stmt='pass', setup='pass', timer=<default timer>, repeat=3, number=1000000, globals=None)
72+
.. function:: repeat(stmt='pass', setup='pass', timer=<default timer>, repeat=5, number=1000000, globals=None)
7373

7474
Create a :class:`Timer` instance with the given statement, *setup* code and
7575
*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:
7979
.. versionchanged:: 3.5
8080
The optional *globals* parameter was added.
8181

82+
.. versionchanged:: 3.7
83+
Default value of *repeat* changed from 3 to 5.
84+
8285
.. function:: default_timer()
8386

8487
The default timer, which is always :func:`time.perf_counter`.
@@ -150,7 +153,7 @@ The module defines three convenience functions and a public class:
150153
.. versionadded:: 3.6
151154

152155

153-
.. method:: Timer.repeat(repeat=3, number=1000000)
156+
.. method:: Timer.repeat(repeat=5, number=1000000)
154157

155158
Call :meth:`.timeit` a few times.
156159

@@ -171,6 +174,9 @@ The module defines three convenience functions and a public class:
171174
should be interested in. After that, you should look at the entire
172175
vector and apply common sense rather than statistics.
173176

177+
.. versionchanged:: 3.7
178+
Default value of *repeat* changed from 3 to 5.
179+
174180

175181
.. method:: Timer.print_exc(file=None)
176182

@@ -208,7 +214,7 @@ Where the following options are understood:
208214

209215
.. cmdoption:: -r N, --repeat=N
210216

211-
how many times to repeat the timer (default 3)
217+
how many times to repeat the timer (default 5)
212218

213219
.. cmdoption:: -s S, --setup=S
214220

@@ -246,7 +252,7 @@ successive powers of 10 until the total time is at least 0.2 seconds.
246252
:func:`default_timer` measurements can be affected by other programs running on
247253
the same machine, so the best thing to do when accurate timing is necessary is
248254
to repeat the timing a few times and use the best time. The :option:`-r`
249-
option is good for this; the default of 3 repetitions is probably enough in
255+
option is good for this; the default of 5 repetitions is probably enough in
250256
most cases. You can use :func:`time.process_time` to measure CPU time.
251257

252258
.. note::

Lib/timeit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
1414
Options:
1515
-n/--number N: how many times to execute 'statement' (default: see below)
16-
-r/--repeat N: how many times to repeat the timer (default 3)
16+
-r/--repeat N: how many times to repeat the timer (default 5)
1717
-s/--setup S: statement to be executed once initially (default 'pass').
1818
Execution time of this setup statement is NOT timed.
1919
-p/--process: use time.process_time() (default is time.perf_counter())
@@ -184,7 +184,7 @@ def repeat(self, repeat=default_repeat, number=default_number):
184184
185185
This is a convenience function that calls the timeit()
186186
repeatedly, returning a list of results. The first argument
187-
specifies how many times to call timeit(), defaulting to 3;
187+
specifies how many times to call timeit(), defaulting to 5;
188188
the second argument specifies the timer argument, defaulting
189189
to one million.
190190

0 commit comments

Comments
 (0)