#18588: merge with 3.4.

This commit is contained in:
Ezio Melotti 2014-08-04 17:01:48 +03:00
commit b398d3e441
1 changed files with 10 additions and 9 deletions

View File

@ -28,22 +28,23 @@ can be used to compare three different expressions:
.. code-block:: sh .. code-block:: sh
$ python -m timeit '"-".join(str(n) for n in range(100))' $ python3 -m timeit '"-".join(str(n) for n in range(100))'
10000 loops, best of 3: 40.3 usec per loop 10000 loops, best of 3: 30.2 usec per loop
$ python -m timeit '"-".join([str(n) for n in range(100)])' $ python3 -m timeit '"-".join([str(n) for n in range(100)])'
10000 loops, best of 3: 33.4 usec per loop 10000 loops, best of 3: 27.5 usec per loop
$ python -m timeit '"-".join(map(str, range(100)))' $ python3 -m timeit '"-".join(map(str, range(100)))'
10000 loops, best of 3: 25.2 usec per loop 10000 loops, best of 3: 23.2 usec per loop
This can be achieved from the :ref:`python-interface` with:: This can be achieved from the :ref:`python-interface` with::
>>> import timeit >>> import timeit
>>> timeit.timeit('"-".join(str(n) for n in range(100))', number=10000) >>> timeit.timeit('"-".join(str(n) for n in range(100))', number=10000)
0.8187260627746582 0.3018611848820001
>>> timeit.timeit('"-".join([str(n) for n in range(100)])', number=10000) >>> timeit.timeit('"-".join([str(n) for n in range(100)])', number=10000)
0.7288308143615723 0.2727368790656328
>>> timeit.timeit('"-".join(map(str, range(100)))', number=10000) >>> timeit.timeit('"-".join(map(str, range(100)))', number=10000)
0.5858950614929199 0.23702679807320237
Note however that :mod:`timeit` will automatically determine the number of Note however that :mod:`timeit` will automatically determine the number of
repetitions only when the command-line interface is used. In the repetitions only when the command-line interface is used. In the