On Fri, May 24, 2013 at 4:22 PM, Szymon Guz <mabewlun@gmail.com> wrote: > Hm... maybe you're right. I think I don't understand fully how the > procedures are executed, and I need to read more to get it.
Well, it's easy.
Instead of PLyFloat_FromNumeric[0], you can make a PLyDecimal_FromNumeric. There, you'd do with the Python/C[1]:
Add of course all kinds of error checking and reference count boiler plate, and you'd have a very dumb version of it.
To make it more "pro", you'd want to do all that stuff to get decimal_ctor only at initialization time. Especially since you don't want to fumble with the import lock right there in _FromNumeric.
And to make it totally "pro", you can even freeze Decimal (using pyfreeze) if you'd like. I would only do this in contexts where you don't have a stdlib of course. Not sure whether windows falls into that category. Linux doesn't.