bpo-35138: Added an example for timeit.timeit with callable arguments… · python/cpython@7f485ea

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