On Sun, 03 Aug 2008 09:46:45 -0500, Rob Williscroft wrote:
> Steven D'Aprano wrote in news:[EMAIL PROTECTED]
> 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
Steven D'Aprano wrote in news:[EMAIL PROTECTED] 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
calle
I think you are confusing 2 people in this thread but that doesn't
really matter.
What surprised me was that I didn't think fib would benefit from
memoization because it didn't repeat the same calculations. fibmem
without memoization is the classic naive implementation that grows
exponentially and
On Sat, 02 Aug 2008 16:14:11 -0500, Rob Williscroft wrote:
> Stefaan Himpe wrote in news:[EMAIL PROTECTED] in
> comp.lang.python:
>
>> 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
On Sat, 02 Aug 2008 06:02:02 -0700, ssecorp wrote:
> I am not clear about the results here.
>
>
> from timeit import Timer
> import Decorators
>
> def fib(n):
> a, b = 1, 0
> while n:
> a, b, n = b, a+b, n-1
> return b
[...]
> s = 100
>
> t1 = Timer('fib(s)', 'from __main
Stefaan Himpe wrote in news:[EMAIL PROTECTED] in
comp.lang.python:
> 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 p
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
I am not clear about the results here.
from timeit import Timer
import Decorators
def fib(n):
a, b = 1, 0
while n:
a, b, n = b, a+b, n-1
return b
@Decorators.memoize
def fibmem(nbr):
if nbr > 1:
return fibmem(nbr-1) + fibmem(nbr-2)
if nbr == 1:
return