summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Hovmöller <boxed@killingar.net>2019-05-13 19:27:17 (GMT)
committerVictor Stinner <vstinner@redhat.com>2019-05-13 19:27:17 (GMT)
commit8da5ebe11e0cb6599af682b22f7c2b2b7b9debd8 (patch)
tree55f8dc236e76521dd4b56fd441f021b236055605
parentb6a09ae287e253e4146a5a224b75d4dbfd38cb63 (diff)
downloadcpython-8da5ebe11e0cb6599af682b22f7c2b2b7b9debd8.zip
cpython-8da5ebe11e0cb6599af682b22f7c2b2b7b9debd8.tar.gz
cpython-8da5ebe11e0cb6599af682b22f7c2b2b7b9debd8.tar.bz2
bpo-35138: Added an example for timeit.timeit with callable arguments (GH-9787)
* Update timeit.rst
-rw-r--r--Doc/library/timeit.rst6
1 files changed, 5 insertions, 1 deletions
diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst
index 8ca3703..ef7a4e4 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.