2**HUGENUMBER Why not optimise it?

Tim Peters tim.one at comcast.net
Fri May 24 21:13:49 EDT 2002


[Michael Hudson]
> ...
> PS: longobject.c is surely the most horrible bit of source in the
>     Python distribution.  I certainly wouldn't want to hack on it.

Give it a try!  You'd be surprised.  A saving grace is that operations on
longs are very well defined, and independent of competing Standard Committee
whims.  For this reason, longobject.c is one of the most #ifdef-free of all
the Python modules, and the ifdefs it does suffer (on HAVE_LONG_LONG and
Py_USING_UNICODE) don't really have anything to do with longs.  So this is a
refreshingly Dead Right versus Dead Wrong module.

The only *artificial* pain (== not inherent to the subject matter) is due to
implementing portable numerics in a language (C) that leaves lots of crucial
issues undefined (like how many bits a thing has, and how sign bits work in
all cases).  It's also one of the more algorithmically interesting modules.
Just pray that x_divrem never sprouts a bug <0.89 wink>.






More information about the Python-list mailing list