[DB-SIG] Accepted method for handling decimals?

Federico Di Gregorio fog at initd.org
Mon Nov 28 17:21:52 CET 2005

Il giorno lun, 28/11/2005 alle 10.40 -0500, Carsten Haese ha scritto:
> Hi everybody:
> I am planning to implement support for decimals in InformixDB
> (http://informixdb.sourceforge.net) using the python decimal module if
> it's available. My question is, should fetches simply return Decimal
> instances instead of floats, or should there be some kind of
> configuration setting to choose whether to return floats or Decimals? If
> so, on what level should that setting reside, module, connection, or
> cursor?

I'd return decimals by default (actually psycopg 2 does.) If the
programmer uses a money or decimal column then it probably does not want
the rouding errors of float point numbers. He will be more than happy to
incur in a small performance penalty to have "exact" numbers.

About the configuration, psycopg just allow the programmer to override
any of the default "type caster" functions with a user-defined one.
Really usefull.


Federico Di Gregorio                         http://people.initd.org/fog
Debian GNU/Linux Developer                                fog at debian.org
INIT.D Developer                                           fog at initd.org
                        Su grappe nessuno è innocente. -- Natale Titotto
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Questa parte del messaggio =?ISO-8859-1?Q?=E8?= firmata
Url : http://mail.python.org/pipermail/db-sig/attachments/20051128/93c44ef7/attachment.pgp

More information about the DB-SIG mailing list