bpo-35138: Added an example for timeit.timeit with callable arguments (GH-9787)

* Update timeit.rst
(cherry picked from commit 8da5ebe11e)

Co-authored-by: Anders Hovmöller <boxed@killingar.net>
This commit is contained in:
Miss Islington (bot) 2019-05-13 12:41:31 -07:00 committed by GitHub
parent ee9b5ce390
commit 7f485ea4fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View 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.