[patch] PL/Python is too lossy with floats - Mailing list pgsql-hackers

From Marko Kreen
Subject [patch] PL/Python is too lossy with floats
Date
Msg-id 20150303143216.GA12187@gmail.com
Whole thread Raw
Responses Re: [patch] PL/Python is too lossy with floats  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
PL/Python uses str(v) to convert float data, but is lossy
by design.  Only repr(v) is guaranteed to have enough
precision to make floats roundtrip properly:

  https://docs.python.org/2/library/functions.html#func-repr
  https://docs.python.org/2/library/functions.html#str

Example:

  $ python
  >>> repr(100100100.654321)
  '100100100.654321'
  >>> str(100100100.654321)
  '100100100.654'

Attached patch uses PyObject_Repr() for float data.

As it's annoying-to-debug problem and the patch is simple,
perhaps it's worth backporting?

--
marko


Attachment

pgsql-hackers by date:

Previous
From: Jan de Visser
Date:
Subject: Re: Idea: closing the loop for "pg_ctl reload"
Next
From: Tom Lane
Date:
Subject: Re: autogenerated column names + views are a dump hazard