[DB-SIG] Looking for objections to adding decimal numbers to Python

M.-A. Lemburg mal@lemburg.com
Thu, 09 Jan 2003 11:54:26 +0100


[this discussion should take place on python-dev rather than db-sig]

Michael McLay wrote:
> On Friday 20 December 2002 07:58 am, Michael McLay wrote:
> 
>>There has been a discusion of adding a "decimal" number type to core
>>distribution on the python-dev mailing list over the past couple weeks.
>>This new type would likely be used most often for financial data that is
>>stored in SQL databases. Tim Peters describes two different types of
>>decimal numbers in the forwarded message that is attached to this message.
>>I do not have the insight into the typical SQL database use of decimal
>>numbers. Are they the fixed point type numbers that Tim has implemented in
>>FixedType (with "banker" rounding properties), or are they  the Cowlishhaw
>>float numbers as described by Tim? My objective in pushing for adding a
>>decimal type is to have useful decimal numbers that for manipulating data
>>from SQL databases added to Python, I'd like to make sure those numbers
>>have the right semantics for that goal.
>>
>>Comments?
> 
> 
> Should FixedPoint [1] be added to the standard distribution? If now, why not?
> 
> The deafening silence suggests either a lack of interest, or poor timing by 
> asking  the question just before a holiday. I hope it was the latter. I think 
> Python deserves a number type that is usable by the financial community. 
> Guido has put off any syntax changes, but at the vary least Python 2.3 should 
> consider adding a "batteries included" module that provides a decimal number 
> capability. 
> 
> It is hard to believe that something that is so fundamental to financial data 
> manipulation can attract less interest than the the addition of the reST 
> module to the standard distribution. Please look at 
> http://fixedpoint.sourceforge.net/ and weigh in on the correctness of this 
> module for use in financial calculations. It is hard to believe that you 
> object to the algorithms used in the implementation of this module (it was 
> written by Tim Peters.) So if you object, please provide some clue as to why 
> FixedPoint doesn't meet your requirements. 
> 
> [1] http://fixedpoint.sourceforge.net/

I suppose for it to be useful for databas processing some things
are still missing:

* a change in the name: FixedPoint is simply to long; decimal would
   be much nicer, IMHO

* the constructor decimal() should become a Python built-in

* an implementation in C (preferably as new style class)

* a C API which is then made available via Python.h

* an upgrade path for existing DB API modules, such that switching
   to FixedPoint from floats is seemless for users of the new
   data type

* the C type should be a subclass of float, if possible

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting:                               http://www.egenix.com/
Python Software:                    http://www.egenix.com/files/python/