Python in game development? + recFib
Christian Tanzer
tanzer at swing.co.at
Fri Sep 1 03:07:14 EDT 2000
Mike Fletcher <mfletch at tpresence.com> wrote:
> The problem with that particular implementation (elegant as it is) is that
> you wind up creating a cache of potentially hundreds of thousands of
> integers when you only need two for the next value (as far as I can see,
> anyway) here is a somewhat faster version of the same algorithm when you're
> dealing with fairly large numbers (such as fibonacci (100000)).
Well, I'm not in the business of playing with x-large fibonacci
numbers. And sure, one should adapt one's algorithm to the problem
to be solved.
You might overrate the negative effects of using lists of 100000
elements, though. For instance, on my system with 160MB main memory it
hardly makes any visible difference whether you use `xrange (2, n+1)'
or `range (2, n+1)' for n==100000 -- procmeter just shows a tiny
dip in free memory for the `range' version (the speed of your
fibonacci2 is the same for both `range' and `xrange', too).
My-original-point-in-this-thread-wasn't-really-optimization-
of-fibonacci-algorithms, ly
Christian
--
Christian Tanzer tanzer at swing.co.at
Glasauergasse 32 Tel: +43 1 876 62 36
A-1130 Vienna, Austria Fax: +43 1 877 66 92
More information about the Python-list
mailing list