[orm-devel] NUMERICAL and DECIMAL on the Python side

Diedrich Vorberg orm-devel@mailman.tux4web.de
Sat, 7 Dec 2002 02:23:32 +0100


Hallo,

I've read some of psycopg's sourcecode and found that it has a very
flexible type system which can be extended in such a way that you can
map PostgreSQL types to custom Python classes. float was chosen for
NUMERIC and DECIMAL to keep the number of psycopg's dependencies at a
minimum. See Federico Di Gregorio's statement on

   http://lists.initd.org/pipermail/psycopg/2002-April/000991.html

In the same thread on the psycopg list someone suggest the FixedPoint 
module as a storage class for these SQL Types on the Python side. See

   http://fixedpoint.sourceforge.net/html/lib/module-FixedPoint.html

for more on this one. For financial calculations this seems to be the
way to go. I do not really know whether it is well suited for math 
with really big quantities as are NUMERIC and DECIMAL. mx.Number 
looks like a good solution for that.

I guess we need to take both packages into account. Does anyone on
this list know of any other packages for exact arbitrary precision 
math that matches the SQL types better?

Also, I wonder how good these extra dependencies are for orm...

Diedrich

-- 
           _..._                            Diedrich Vorberg
         .'     '.
        /  _   _  \                         http://www.tux4web.de
        | (o)_(o) |                         info@tux4web.de
         \(     ) /            .---.
         //'._.'\ \           /     \       Internet Dienstleistungen
        //   .   \ \          \.@-@./       und 'Consulting'.
       ||   .     \ \         /`\_/`\
       |\   :     / |        //  _  \\      Linux Rules!
       \ `) '   (`  /_      | \     )|_
     _)``".____,.'"` (_    /`\_`>  <_/ \
     )     )'--'(     (    \__/'---'\__/
      '---`      `---`