On 26 June 2013 21:59, Peter Eisentraut <peter_e@gmx.net> wrote:
On 6/26/13 7:03 AM, Szymon Guz wrote: > I've checked the patch, everything looks great. > I've attached it to this email with changed name, just for consistent > naming in commitfest app.
Could the setup of the decimal.Decimal constructor be moved into PLyDecimal_FromNumeric() and kept in a static pointer? I'd rather not clutter up the main initialization routine.
Attached patch has all changes against trunk code.
There is added a function for conversion from Postgres numeric to Python Decimal. The Decimal type is taken from cdecimal.Decimal, if it is available. It is an external library, quite fast, but may be not available. If it is not available, then decimal.Decimal will be used. It is in standard Python library, however it is rather slow.
The initialization is done in the conversion function, the pointer to a proper Decimal constructor is stored as static variable inside the function and is lazy initialized.
The documentation is updated.
Tests for python 2 and 3 have been added. They work only with standard decimal.Decimal, as the type is printed in the *.out files. I think there is nothing we can do with that now.