Skip to content

bpo-35138: Added an example for timeit.timeit with callable arguments #9787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Doc/library/timeit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down