[Python-Dev] Expert floats

Aahz aahz at pythoncraft.com
Wed Mar 31 00:47:50 EST 2004


On Tue, Mar 30, 2004, Andrew P. Lentvorski, Jr. wrote:
>
> My question is: Is it possible that a C implementation of Decimal
> would be almost as fast as native floating point in Python for
> reasonable digit lengths and settings? (ie. use native FP as an
> approximation and then do some tests to get the last digit right).

Basic answer: yes, for people not doing serious number crunching

> This is similar to the long int/int unification.  Long ints are slow,
> but things are okay as long as the numbers are within the native
> range.  The hope would be that Decimal configurations which fit within
> the machine format are reasonably fast, but things outside it slow
> down.

Well, that won't happen.  The long/int issue at least has compatibility
at the binary level; binary/decimal conversions lead us right back to
the problems that Decimal is trying to fix.

> Please note that nowhere did I comment that creating such a C
> implementation of Decimal would be easy or even possible. ;)

Actually, the whole point of the Decimal class is that it's easy to
implement.  Once we agree on the API and semantics, converting to C
should be not much harder than trivial.

Although I ended up dropping the ball, that's the whole reason I got
involved with Decimal in the first place: the intention is that Decimal
written in C will release the GIL.  It will be an experiment in
computational threading.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"usenet imitates usenet"  --Darkhawk



More information about the Python-Dev mailing list