summaryrefslogtreecommitdiffstats
path: root/Doc/lib/libtimeit.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/lib/libtimeit.tex')
-rw-r--r--Doc/lib/libtimeit.tex16
1 files changed, 8 insertions, 8 deletions
diff --git a/Doc/lib/libtimeit.tex b/Doc/lib/libtimeit.tex
index 1c4e05b..2629439 100644
--- a/Doc/lib/libtimeit.tex
+++ b/Doc/lib/libtimeit.tex
@@ -162,13 +162,13 @@ the module interface) that compare the cost of using
missing and present object attributes.
\begin{verbatim}
-% timeit.py 'try:' ' str.__nonzero__' 'except AttributeError:' ' pass'
+% timeit.py 'try:' ' str.__bool__' 'except AttributeError:' ' pass'
100000 loops, best of 3: 15.7 usec per loop
-% timeit.py 'if hasattr(str, "__nonzero__"): pass'
+% timeit.py 'if hasattr(str, "__bool__"): pass'
100000 loops, best of 3: 4.26 usec per loop
-% timeit.py 'try:' ' int.__nonzero__' 'except AttributeError:' ' pass'
+% timeit.py 'try:' ' int.__bool__' 'except AttributeError:' ' pass'
1000000 loops, best of 3: 1.43 usec per loop
-% timeit.py 'if hasattr(int, "__nonzero__"): pass'
+% timeit.py 'if hasattr(int, "__bool__"): pass'
100000 loops, best of 3: 2.23 usec per loop
\end{verbatim}
@@ -176,7 +176,7 @@ missing and present object attributes.
>>> import timeit
>>> s = """\
... try:
-... str.__nonzero__
+... str.__bool__
... except AttributeError:
... pass
... """
@@ -184,14 +184,14 @@ missing and present object attributes.
>>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000)
17.09 usec/pass
>>> s = """\
-... if hasattr(str, '__nonzero__'): pass
+... if hasattr(str, '__bool__'): pass
... """
>>> t = timeit.Timer(stmt=s)
>>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000)
4.85 usec/pass
>>> s = """\
... try:
-... int.__nonzero__
+... int.__bool__
... except AttributeError:
... pass
... """
@@ -199,7 +199,7 @@ missing and present object attributes.
>>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000)
1.97 usec/pass
>>> s = """\
-... if hasattr(int, '__nonzero__'): pass
+... if hasattr(int, '__bool__'): pass
... """
>>> t = timeit.Timer(stmt=s)
>>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000)