Sam Kellett Sam Kellett - 8 months ago 25
Python Question

How do I create a Python Decimal object from C++?

...or any Python object that exists in an importable library. I have found PyDateTime_* functions in the documentation for creating objects from the datetime module, but I can't find anything to do with the python decimal module. Is this possible?

Looking for a Boost.Python way if there is one, but the native API's will suffice if not.


In Boost.Python that would be something like

bp::object decimal = bp::import("decimal").attr("Decimal");
bp::object decimal_obj = decimal(1, 4);