summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorSkip Montanaro <skip@pobox.com>2003-05-09 18:21:02 (GMT)
committerSkip Montanaro <skip@pobox.com>2003-05-09 18:21:02 (GMT)
commita30dffbb53544a864fa881e96416a97c788ed1a3 (patch)
treeec5fd0bd4e4d6547b146161a478d70cf2bd53dd7 /Doc
parent3ec4dfd812ef57cd7fedd9ba80eb4bc0b072b7da (diff)
downloadcpython-a30dffbb53544a864fa881e96416a97c788ed1a3.zip
cpython-a30dffbb53544a864fa881e96416a97c788ed1a3.tar.gz
cpython-a30dffbb53544a864fa881e96416a97c788ed1a3.tar.bz2
add a note about accessing user-defined functions with an import statement
in the setup parameter
Diffstat (limited to 'Doc')
-rw-r--r--Doc/lib/libtimeit.tex17
1 files changed, 17 insertions, 0 deletions
diff --git a/Doc/lib/libtimeit.tex b/Doc/lib/libtimeit.tex
index bde25f8..882cad1 100644
--- a/Doc/lib/libtimeit.tex
+++ b/Doc/lib/libtimeit.tex
@@ -193,3 +193,20 @@ missing and present object attributes.
>>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000)
3.15 usec/pass
\end{verbatim}
+
+To give the \module{timeit} module access to functions you
+define, you can pass a \code{setup} parameter which contains an import
+statement:
+
+\begin{verbatim}
+def test():
+ "Stupid test function"
+ L = []
+ for i in range(100):
+ L.append(i)
+
+if __name__=='__main__':
+ from timeit import Timer
+ t = Timer("test()", "from __main__ import test")
+ print t.timeit()
+\end{verbatim}