The following stats are Fibonacci function call stats
Here are some Stats I got after running profiler
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]
57358 function calls (68 primitive calls) in 0.211 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
21 0.000 0.000 0.000 0.000 :0(append)
1 0.000 0.000 0.210 0.210 :0(exec)
20 0.000 0.000 0.000 0.000 :0(extend)
1 0.000 0.000 0.000 0.000 :0(print)
1 0.001 0.001 0.001 0.001 :0(setprofile)
1 0.000 0.000 0.210 0.210 <string>:1(<module>)
21/1 0.000 0.000 0.210 0.210 Fibo1.py:12(fib_seq)
57291/21 0.210 0.000 0.210 0.010 Fibo1.py:3(fib)
1 0.000 0.000 0.211 0.211 profile:0(print(fib_seq(20)) )
0 0.000 0.000 profile:0(profiler)
And After using memoization the profiler stats
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]
147 function calls (89 primitive calls) in 0.002 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
21 0.000 0.000 0.000 0.000 :0(append)
1 0.000 0.000 0.001 0.001 :0(exec)
20 0.000 0.000 0.000 0.000 :0(extend)
1 0.000 0.000 0.000 0.000 :0(print)
1 0.001 0.001 0.001 0.001 :0(setprofile)
1 0.000 0.000 0.001 0.001 <string>:1(<module>)
21 0.000 0.000 0.000 0.000 Fibo2.py:16(fib)
21/1 0.000 0.000 0.001 0.001 Fibo2.py:26(fib_seq)
59/21 0.000 0.000 0.000 0.000 Fibo2.py:9(__call__)
1 0.000 0.000 0.002 0.002 profile:0(print(fib_seq(20)))
0 0.000 0.000 profile:0(profiler)
the total function calls reduced by great numbers.If possible please provide some links for more details regarding memoization.