Profiling weirdness: Timer.timeit(), fibonacci and memoization

Stefaan Himpe stefaan.himpe at gmail.com
Sat Aug 2 22:22:43 CEST 2008


Nothing weird about this ...
The difference will become larger as your input value becomes larger.

You can easily understand why if you try to calculate fib(10) by hand,
i.e. work through the algorithm with pencil and paper,
then compare the work you have to do to the memoized version which just 
takes fib(9) and fib(8) from memory and adds them together.

Best regards,
Stefaan.



More information about the Python-list mailing list