[EMAIL PROTECTED] (David M. Cooke) wrote:
> > It seems kind of surprising that I can't time functions. Am I just not
> > seeing something obvious?
>
> Like the documentation for Timer? :-)
>
> class Timer([stmt='pass' [, setup='pass' [, timer=]]])
>
> You can't use statements defined elsewhe
Roy Smith <[EMAIL PROTECTED]> writes:
> I'm playing with the timeit module, and can't figure out how to time a
> function call. I tried:
>
> def foo ():
> x = 4
> return x
>
> t = timeit.Timer ("foo()")
> print t.timeit()
>
> and quickly figured out that the environment the timed code ru
I use a little wrapper to timeit:
$ cat timeit_.py
import timeit, __main__, warnings
warnings.filterwarnings('ignore',
'import \* only allowed at module level',SyntaxWarning)
def timeit(stmt, setup='from __main__ import *', n=1000):
t = timeit.Timer(stmt,setup)
try: print t.repeat(numb
I'm playing with the timeit module, and can't figure out how to time a
function call. I tried:
def foo ():
x = 4
return x
t = timeit.Timer ("foo()")
print t.timeit()
and quickly figured out that the environment the timed code runs under
is not what I expected:
Traceback (most recent