X-Original-To: pgsql-interfaces@PostgreSQL.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A6F86474E4F for ; Wed, 26 Feb 2003 08:53:24 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 57485-07 for ; Wed, 26 Feb 2003 08:53:14 -0500 (EST) Received: from druid.net (druid.net [216.126.72.98]) by postgresql.org (Postfix) with ESMTP id D6C72475A4B for ; Wed, 26 Feb 2003 08:53:13 -0500 (EST) Received: by druid.net (Postfix, from userid 1000) id 72DCA1A7D; Wed, 26 Feb 2003 08:53:19 -0500 (EST) Content-Type: text/plain; charset="iso-8859-1" From: "D'Arcy J.M. Cain" Reply-To: pgsql-interfaces@PostgreSQL.org To: Joel Mc Graw Subject: Re: Python interface and Money? Date: Wed, 26 Feb 2003 08:53:18 -0500 User-Agent: KMail/1.4.3 References: <3BD45B33.C217E6FF@databill.com> In-Reply-To: <3BD45B33.C217E6FF@databill.com> Cc: pgsql-interfaces@PostgreSQL.org MIME-Version: 1.0 Message-Id: <200302260853.18997.darcy@druid.net> Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/110 X-Sequence-Number: 3731 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=20 closest thing we can convert to is float. There have been attempts at a=20 decimal type and at some point I will convert to one of them, hopefully the= =20 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= =20 purpose. I think that it needs to move to a 64 bit int and handle a lot mo= re=20 type conversions but I moved some stuff to numeric due to the limits and=20 found a noticeable slowdown when working with lots of aggregates on it. Th= e=20 int type is just more efficient. I plan on making a contrib version of the= =20 type before it gets deleted if that is what is decided. --=20 D'Arcy J.M. Cain | 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.