@@ -27,11 +27,11 @@ can be used to compare three different expressions:
27
27
28
28
.. code-block :: shell-session
29
29
30
- $ python -m timeit '"-" .join(str(n) for n in range(100))'
30
+ $ python -m timeit "'-' .join(str(n) for n in range(100))"
31
31
10000 loops, best of 5: 30.2 usec per loop
32
- $ python -m timeit '"-" .join([str(n) for n in range(100)])'
32
+ $ python -m timeit "'-' .join([str(n) for n in range(100)])"
33
33
10000 loops, best of 5: 27.5 usec per loop
34
- $ python -m timeit '"-" .join(map(str, range(100)))'
34
+ $ python -m timeit "'-' .join(map(str, range(100)))"
35
35
10000 loops, best of 5: 23.2 usec per loop
36
36
37
37
This can be achieved from the :ref: `python-interface ` with::
@@ -277,9 +277,9 @@ It is possible to provide a setup statement that is executed only once at the be
277
277
278
278
.. code-block :: shell-session
279
279
280
- $ python -m timeit -s ' text = " sample string" ; char = "g"' ' char in text'
280
+ $ python -m timeit -s " text = ' sample string' ; char = 'g'" " char in text"
281
281
5000000 loops, best of 5: 0.0877 usec per loop
282
- $ python -m timeit -s ' text = " sample string" ; char = "g"' ' text.find(char)'
282
+ $ python -m timeit -s " text = ' sample string' ; char = 'g'" " text.find(char)"
283
283
1000000 loops, best of 5: 0.342 usec per loop
284
284
285
285
In the output, there are three fields. The loop count, which tells you how many
@@ -313,14 +313,14 @@ to test for missing and present object attributes:
313
313
314
314
.. code-block :: shell-session
315
315
316
- $ python -m timeit ' try:' ' str.__bool__' ' except AttributeError:' ' pass'
316
+ $ python -m timeit " try:" " str.__bool__" " except AttributeError:" " pass"
317
317
20000 loops, best of 5: 15.7 usec per loop
318
- $ python -m timeit ' if hasattr(str, " __bool__" ): pass'
318
+ $ python -m timeit " if hasattr(str, ' __bool__' ): pass"
319
319
50000 loops, best of 5: 4.26 usec per loop
320
320
321
- $ python -m timeit ' try:' ' int.__bool__' ' except AttributeError:' ' pass'
321
+ $ python -m timeit " try:" " int.__bool__" " except AttributeError:" " pass"
322
322
200000 loops, best of 5: 1.43 usec per loop
323
- $ python -m timeit ' if hasattr(int, " __bool__" ): pass'
323
+ $ python -m timeit " if hasattr(int, ' __bool__' ): pass"
324
324
100000 loops, best of 5: 2.23 usec per loop
325
325
326
326
::
0 commit comments