[Python-checkins] bpo-35138: Added an example for timeit.timeit with callable arguments (GH-9787)
Miss Islington (bot)
webhook-mailer at python.org
Mon May 13 15:41:35 EDT 2019
https://github.com/python/cpython/commit/7f485ea4fc17c5afb38cd0478ff15326fb5a47fc
commit: 7f485ea4fc17c5afb38cd0478ff15326fb5a47fc
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-05-13T12:41:31-07:00
summary:
bpo-35138: Added an example for timeit.timeit with callable arguments (GH-9787)
* Update timeit.rst
(cherry picked from commit 8da5ebe11e0cb6599af682b22f7c2b2b7b9debd8)
Co-authored-by: Anders Hovmöller <boxed at killingar.net>
files:
M Doc/library/timeit.rst
diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst
index 8ca37034f79b..ef7a4e40be65 100644
--- a/Doc/library/timeit.rst
+++ b/Doc/library/timeit.rst
@@ -44,8 +44,12 @@ This can be achieved from the :ref:`python-interface` with::
>>> timeit.timeit('"-".join(map(str, range(100)))', number=10000)
0.23702679807320237
+A callable can also be passed from the :ref:`python-interface`::
-Note however that :mod:`timeit` will automatically determine the number of
+ >>> timeit.timeit(lambda: "-".join(map(str, range(100))), number=10000)
+ 0.19665591977536678
+
+Note however that :func:`.timeit` will automatically determine the number of
repetitions only when the command-line interface is used. In the
:ref:`timeit-examples` section you can find more advanced examples.
More information about the Python-checkins
mailing list