Faster Recursive Fibonacci Numbers

Chris Angelico rosuav at gmail.com
Fri May 20 02:54:06 EDT 2011


On Fri, May 20, 2011 at 4:26 PM, harrismh777 <harrismh777 at charter.net> wrote:
> Actually, it should be relatively easy to incorporate parts of bc into
> Python as C extensions. On the other hand, when needing specialized math
> work from bc, its probably just better to use bc and leave Python alone.

If someone has time to kill (as if!), it'd be awesome to get a new
numeric type that uses bc's code; any other numeric type (int, long,
float) could autopromote to it, removing the dilemma of which to
promote out of long and float. Hmm... Python 4.0, 'bc' is the new
default integer and everything else is a performance optimization?
Heh.

> On the other hand, most of the time (and I mean 99.999% of the time) floats
> are going to work just fine... usually folks don't even need doubles....
> :)

99.9% of the time int will work fine, too. Most people don't need
arbitrary precision OR floating point.

> Don't get me wrong... I absolutely love playing around with bignums, but
> then, I'm a math geek...    ;-)

Absolutely. Bring on the geekiness.

I've used bignums for things other than straight arithmetic, actually.
In REXX, where everything is a string, I've done some fascinating (and
completely useless) analyses that involve taking internal digits from
a number, performing arithmetic on them, getting huge numbers back,
and then searching for substrings (ie digit strings) in the result.
What's the lowest power of 2 that has 5 consecutive digits in it? All
10 digits? (That is, it has '0123456789' somewhere in its decimal
representation.)

Like I said, completely useless... but how many of you immediately
pondered which language to implement the search in?

Chris Angelico



More information about the Python-list mailing list