Re: [PATCH] Fix conversion for Decimal arguments in plpython functions
От | Szymon Guz |
---|---|
Тема | Re: [PATCH] Fix conversion for Decimal arguments in plpython functions |
Дата | |
Msg-id | CAFjNrYt6o61d-TqoL=yFfHrVSy6o2Tqq-joCsn54CZPsYYPZBg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: [PATCH] Fix conversion for Decimal arguments in plpython functions (Szymon Guz <mabewlun@gmail.com>) |
Ответы |
Re: [PATCH] Fix conversion for Decimal arguments in plpython
functions
|
Список | pgsql-hackers |
On 26 June 2013 22:08, Szymon Guz <mabewlun@gmail.com> wrote:
On 26 June 2013 21:59, Peter Eisentraut <peter_e@gmx.net> wrote:On 6/26/13 7:03 AM, Szymon Guz wrote:Could the setup of the decimal.Decimal constructor be moved into
> 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.
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.
regards,
Szymon
Вложения
В списке pgsql-hackers по дате отправления: