Re: Python interface and Money? - Mailing list pgsql-interfaces

From D'Arcy J.M. Cain
Subject Re: Python interface and Money?
Date
Msg-id 200302260853.18997.darcy@druid.net
Whole thread Raw
In response to Python interface and Money?  (Joel Mc Graw <jmcgraw@databill.com>)
Responses Re: Python interface and Money?
List pgsql-interfaces
On Monday 22 October 2001 13:45, Joel Mc Graw wrote:
> I have a table that has a column of type money.  A query such as "select
> sum(document_amount) from foo" returns the correct result when executed
> from psql, yet the same query returns the wrong answer (it appears to be
> a rounding issue--something like "1234.9999999999...") when executed
> through PygreSQL.  Is there a workaround or a fix?

The problem is that Python doesn't (yet) have a native decimal type and so the
closest thing we can convert to is float.  There have been attempts at a
decimal type and at some point I will convert to one of them, hopefully the
same one that Python chooses as a standard.

> While browsing the mailing list for an answer to this problem I found
> several references to the money type being deprecated.  Is that the
> problem?

There are people who want to remove it but I still think it serves a useful
purpose.  I think that it needs to move to a 64 bit int and handle a lot more
type conversions but I moved some stuff to numeric due to the limits and
found a noticeable slowdown when working with lots of aggregates on it.  The
int type is just more efficient.  I plan on making a contrib version of the
type before it gets deleted if that is what is decided.

--
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.


pgsql-interfaces by date:

Previous
From: Tom Lane
Date:
Subject: Re: debug a mess
Next
From: "D'Arcy J.M. Cain"
Date:
Subject: Re: Python interface and Money?