Skip to content

Commit 8da5ebe

Browse files
boxedvstinner
authored andcommitted
bpo-35138: Added an example for timeit.timeit with callable arguments (GH-9787)
* Update timeit.rst
1 parent b6a09ae commit 8da5ebe

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Doc/library/timeit.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ This can be achieved from the :ref:`python-interface` with::
4444
>>> timeit.timeit('"-".join(map(str, range(100)))', number=10000)
4545
0.23702679807320237
4646

47+
A callable can also be passed from the :ref:`python-interface`::
4748

48-
Note however that :mod:`timeit` will automatically determine the number of
49+
>>> timeit.timeit(lambda: "-".join(map(str, range(100))), number=10000)
50+
0.19665591977536678
51+
52+
Note however that :func:`.timeit` will automatically determine the number of
4953
repetitions only when the command-line interface is used. In the
5054
:ref:`timeit-examples` section you can find more advanced examples.
5155

0 commit comments

Comments
 (0)