timeit.timeit and timeit.repeat give different answers

Peter Otten __peter__ at web.de
Wed Jul 14 08:54:21 CEST 2004


Dan Christensen wrote:

> Hmm, if I type this at the python prompt:
> 
> r = []
> for i in range(1):  # Note: only one loop!
>     ti = t.timeit()
>     r.append(ti)
> print r
> 
> I get data that agrees with t.repeat but disagrees with:

...

> t.timeit()

You could try "intermediate simplifications" to spot the culprit:

r = [None]
for i in range(1):
    r[i] = t.timeit()

and

for i in range(1): 
    ti = t.timeit()

I've no idea what's happening.

Peter




More information about the Python-list mailing list