kahofanfan
kahofanfan

Reputation: 297

less time used with larger number in timeit.timeit()?

import timeit
t=timeit.timeit('x=map(lambda x:x*10,range(32))')
print(t)

which shows:

0.4678139

but

t=timeit.timeit('x=map(lambda x:x*10,range(32))',number=100)
print(t)

gives:

4.309999999999731e-05

I suppose number=100 should takes 100 times 0.4678139, so what's wrong here?

Upvotes: 2

Views: 150

Answers (1)

Iguananaut
Iguananaut

Reputation: 23356

The default arguments for timer.timeit include number=1000000, hence your first result is quite close to 1e4 times the second.

Upvotes: 2

Related Questions