From 7919398bac8bacd75ec5d763ce8b15ffaaa3e071 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 5 Jul 2013 22:41:25 -0400 Subject: PL/Python: Convert numeric to Decimal The old implementation converted PostgreSQL numeric to Python float, which was always considered a shortcoming. Now numeric is converted to the Python Decimal object. Either the external cdecimal module or the standard library decimal module are supported. From: Szymon Guz From: Ronan Dunklau Reviewed-by: Steve Singer --- doc/src/sgml/plpython.sgml | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/plpython.sgml b/doc/src/sgml/plpython.sgml index aaf758d4959..ad89355d60d 100644 --- a/doc/src/sgml/plpython.sgml +++ b/doc/src/sgml/plpython.sgml @@ -310,12 +310,23 @@ $$ LANGUAGE plpythonu; - PostgreSQL real, double, - and numeric are converted to - Python float. Note that for - the numeric this loses information and can lead to - incorrect results. This might be fixed in a future - release. + PostgreSQL real and double are converted to + Python float. + + + + + + PostgreSQL numeric is converted to + Python Decimal. This type is imported from + the cdecimal package if that is available. + Otherwise, + decimal.Decimal from the standard library will be + used. cdecimal is significantly faster + than decimal. In Python 3.3, + however, cdecimal has been integrated into the + standard library under the name decimal, so there is + no longer any difference. -- cgit v1.2.3