On 17/06/20 8:32 am, Daniele Nicolodi wrote:
PyObject* decimal = PyImport_ImportModule("decimal");
PyObject* constructor = PyObject_GetAttrString(m, "Decimal");
PyObject* obj = PyObject_CallFunction(PyDec_Type, "s#", str, len);
Is there a better way?
I was thinking about getting to the PyTypeObject for Decimal, like
PyTypeObject* type = Py_TYPE(obj);
That will get you exactly the same object you get by importing
the decimal.Decimal class. In Python3 there is no difference
between a type and a class. So I don't think there's any
substantially faster way.
--
Greg
_______________________________________________
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel