Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
591176e5
Commit
591176e5
authored
Aug 04, 2014
by
Ezio Melotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#18588: update the timeit examples to be consistent.
parent
c6f22cc0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
Doc/library/timeit.rst
Doc/library/timeit.rst
+10
-9
No files found.
Doc/library/timeit.rst
View file @
591176e5
...
...
@@ -28,22 +28,23 @@ can be used to compare three different expressions:
.. code-block:: sh
$ python -m timeit '"-".join(str(n) for n in range(100))'
10000 loops, best of 3:
40.3
usec per loop
$ python -m timeit '"-".join([str(n) for n in range(100)])'
10000 loops, best of 3:
33.4
usec per loop
$ python -m timeit '"-".join(map(str, range(100)))'
10000 loops, best of 3: 2
5
.2 usec per loop
$ python
3
-m timeit '"-".join(str(n) for n in range(100))'
10000 loops, best of 3:
30.2
usec per loop
$ python
3
-m timeit '"-".join([str(n) for n in range(100)])'
10000 loops, best of 3:
27.5
usec per loop
$ python
3
-m timeit '"-".join(map(str, range(100)))'
10000 loops, best of 3: 2
3
.2 usec per loop
This can be achieved from the :ref:`python-interface` with::
>>> import timeit
>>> timeit.timeit('"-".join(str(n) for n in range(100))', number=10000)
0.
8187260627746582
0.
3018611848820001
>>> timeit.timeit('"-".join([str(n) for n in range(100)])', number=10000)
0.
7288308143615723
0.
2727368790656328
>>> timeit.timeit('"-".join(map(str, range(100)))', number=10000)
0.5858950614929199
0.23702679807320237
Note however that :mod:`timeit` will automatically determine the number of
repetitions only when the command-line interface is used. In the
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment