From: D'Arcy J.M. Cain <darcy@druid.net>
To: Joel Mc Graw <jmcgraw@databill.com>
Cc: pgsql-interfaces@PostgreSQL.org
Subject: Re: Python interface and Money?
Date: Wed, 26 Feb 2003 08:53:18 -0500
Message-ID: <200302260853.18997.darcy@druid.net> (raw)
In-Reply-To: <3BD45B33.C217E6FF@databill.com>
References: <3BD45B33.C217E6FF@databill.com>
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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: darcy@druid.net, jmcgraw@databill.com
Subject: Re: Python interface and Money?
In-Reply-To: <200302260853.18997.darcy@druid.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox