[Python-Dev] Expert floats

Andrew P. Lentvorski, Jr. bsder at allcaps.org
Wed Mar 31 00:31:13 EST 2004


On Tue, 30 Mar 2004, Tim Peters wrote:

> The only thing Decimal will have against it in the end is runtime sloth.

While the Decimal implementation is in Python, certainly.

However, I did some floating point calculation timings a while back, and
the Python FP system is slow due to the overhead of working out types,
unpacking the values, and repacking the value.  The actual native
calculation is a small portion of that time.

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).

The intent here is to at least propose as a strawman that Python use a C
implementation of Decimal as its native floating point type.

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.

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

-a



More information about the Python-Dev mailing list