<div dir="ltr"><br /><div class="gmail_extra"><div class="gmail_quote">On 24 May 2013 21:46, Claudio Freire <span
dir="ltr"><<ahref="mailto:klaussfreire@gmail.com" target="_blank">klaussfreire@gmail.com</a>></span> wrote:<br
/><blockquoteclass="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div
class="im">OnFri, May 24, 2013 at 4:22 PM, Szymon Guz <<a
href="mailto:mabewlun@gmail.com">mabewlun@gmail.com</a>>wrote:<br /> > Hm... maybe you're right. I think I don't
understandfully how the<br /> > procedures are executed, and I need to read more to get it.<br /><br /><br
/></div>Well,it's easy.<br /><br /> Instead of PLyFloat_FromNumeric[0], you can make a<br /> PLyDecimal_FromNumeric.
There,you'd do with the Python/C[1]:<br /><br /> PyObject *decimal = PyImport_Import("decimal");<br /> PyObject
*decimal_dict= PyModule_GetDict(decimal);<br /> PyObject *decimal_ctor = PyDict_GetItemString(decimal_dict,
"Decimal");<br/><br /> And invoke it with a string rep of your Numeric:<br /><br /> PyObject *value =
PyObject_CallFunction(decimal_ctor,"S", string_value);<br /><br /> Add of course all kinds of error checking and
referencecount boiler<br /> plate, and you'd have a very dumb version of it.<br /><br /> To make it more "pro", you'd
wantto do all that stuff to get<br /> decimal_ctor only at initialization time. Especially since you don't<br /> want
tofumble with the import lock right there in _FromNumeric.<br /><br /> And to make it totally "pro", you can even
freezeDecimal (using<br /> pyfreeze) if you'd like. I would only do this in contexts where you<br /> don't have a
stdlibof course. Not sure whether windows falls into<br /> that category. Linux doesn't.<br /><br /><br /> [0] <a
href="http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/pl/plpython/plpy_typeio.c#l518"
target="_blank">http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/pl/plpython/plpy_typeio.c#l518</a><br/>
[1]<a href="http://docs.python.org/2/c-api/import.html"
target="_blank">http://docs.python.org/2/c-api/import.html</a><br/></blockquote></div><br /></div><div
class="gmail_extra"style="style"><br /></div><div class="gmail_extra" style="style">Thanks, I will take a look at this,
lookspretty easy. However testing on Windows will be pretty funny :)</div><div class="gmail_extra" style="style"><br
/></div><divclass="gmail_extra" style="style">thanks,</div><div class="gmail_extra" style="style">Szymon</div></div>