Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 591176e

Browse files
committed
#18588: update the timeit examples to be consistent.
1 parent c6f22cc commit 591176e

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

Doc/library/timeit.rst

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,23 @@ can be used to compare three different expressions:
2828

2929
.. code-block:: sh
3030
31-
$ python -m timeit '"-".join(str(n) for n in range(100))'
32-
10000 loops, best of 3: 40.3 usec per loop
33-
$ python -m timeit '"-".join([str(n) for n in range(100)])'
34-
10000 loops, best of 3: 33.4 usec per loop
35-
$ python -m timeit '"-".join(map(str, range(100)))'
36-
10000 loops, best of 3: 25.2 usec per loop
31+
$ python3 -m timeit '"-".join(str(n) for n in range(100))'
32+
10000 loops, best of 3: 30.2 usec per loop
33+
$ python3 -m timeit '"-".join([str(n) for n in range(100)])'
34+
10000 loops, best of 3: 27.5 usec per loop
35+
$ python3 -m timeit '"-".join(map(str, range(100)))'
36+
10000 loops, best of 3: 23.2 usec per loop
3737
3838
This can be achieved from the :ref:`python-interface` with::
3939

4040
>>> import timeit
4141
>>> timeit.timeit('"-".join(str(n) for n in range(100))', number=10000)
42-
0.8187260627746582
42+
0.3018611848820001
4343
>>> timeit.timeit('"-".join([str(n) for n in range(100)])', number=10000)
44-
0.7288308143615723
44+
0.2727368790656328
4545
>>> timeit.timeit('"-".join(map(str, range(100)))', number=10000)
46-
0.5858950614929199
46+
0.23702679807320237
47+
4748

4849
Note however that :mod:`timeit` will automatically determine the number of
4950
repetitions only when the command-line interface is used. In the

0 commit comments

Comments
 (0)