Profiling weirdness: Timer.timeit(), fibonacci and memoization
Rob Williscroft
rtw at freenet.co.uk
Sun Aug 3 10:46:45 EDT 2008
Steven D'Aprano wrote in news:00a529cc$0$20316$c3e8da3 at news.astraweb.com in
comp.lang.python:
>> So the question is: whats going on with timeit.Timer ?
>
> As far as I can see, nothing. I think you have misunderstood the results
> you got.
No, the answer is that is it repeats a million times. It might better be
called repeat_one_million_times().
Or put another way, myself and the OP misinterpreted what the call
t1.repeat( number = 1 ) did.
its a confusing API.
For the OP:
The call t1.timeit() is equivalent to t1.repeat( number = 1000000 ).
So it bennefits from memoization because the call *is* repeated, not
just called once like you intended.
Rob.
--
http://www.victim-prime.dsl.pipex.com/
More information about the Python-list
mailing list