diff options
author | Collin Winter <collinw@gmail.com> | 2007-09-01 23:34:30 (GMT) |
---|---|---|
committer | Collin Winter <collinw@gmail.com> | 2007-09-01 23:34:30 (GMT) |
commit | c79461b1648c9209c3652184572a17eef0a76202 (patch) | |
tree | 47c6238c8c47c4881f6f0523ea86d201cea1fc94 /Doc/library/timeit.rst | |
parent | 2ac012130549b1ef51ebce11148d01eaca1a7033 (diff) | |
download | cpython-c79461b1648c9209c3652184572a17eef0a76202.zip cpython-c79461b1648c9209c3652184572a17eef0a76202.tar.gz cpython-c79461b1648c9209c3652184572a17eef0a76202.tar.bz2 |
Partial py3k-ification of Doc/library/: convert has_key references into either 'k in d' or __contains__; normalize raise statements; convert print statements into print function calls.
Diffstat (limited to 'Doc/library/timeit.rst')
-rw-r--r-- | Doc/library/timeit.rst | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst index bc9615a..3387c7f 100644 --- a/Doc/library/timeit.rst +++ b/Doc/library/timeit.rst @@ -196,13 +196,13 @@ attributes. :: ... pass ... """ >>> t = timeit.Timer(stmt=s) - >>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000) + >>> print("%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000)) 17.09 usec/pass >>> s = """\ ... if hasattr(str, '__bool__'): pass ... """ >>> t = timeit.Timer(stmt=s) - >>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000) + >>> print("%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000)) 4.85 usec/pass >>> s = """\ ... try: @@ -211,13 +211,13 @@ attributes. :: ... pass ... """ >>> t = timeit.Timer(stmt=s) - >>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000) + >>> print("%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000)) 1.97 usec/pass >>> s = """\ ... if hasattr(int, '__bool__'): pass ... """ >>> t = timeit.Timer(stmt=s) - >>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000) + >>> print("%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000)) 3.15 usec/pass To give the :mod:`timeit` module access to functions you define, you can pass a @@ -225,12 +225,10 @@ To give the :mod:`timeit` module access to functions you define, you can pass a def test(): "Stupid test function" - L = [] - for i in range(100): - L.append(i) + L = [i for i in range(100)] if __name__=='__main__': from timeit import Timer t = Timer("test()", "from __main__ import test") - print t.timeit() + print(t.timeit()) |