bpo-35138: Added an example for timeit.timeit with callable arguments (GH-9787)
authorAnders Hovmöller <boxed@killingar.net>
Mon, 13 May 2019 19:27:17 +0000 (21:27 +0200)
committerVictor Stinner <vstinner@redhat.com>
Mon, 13 May 2019 19:27:17 +0000 (21:27 +0200)
* Update timeit.rst

Doc/library/timeit.rst

index 8ca37034f79b7c6a03364fa35ef34834e7b0323c..ef7a4e40be65908cbf8b47fc532b47b9e24a32cd 100644 (file)
@@ -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.