On 2020-01-07 20:22, hrfu...@gmail.com wrote:
Thanks for the suggestion. I haven't looked at PyCXX yet. I'll definitely check
it out sometime. In light of your and other people's replies, I probably will
postpone the development till I think it through, especially after another day
of trying and failing.
I do have one question for you, and for anyone who is kind enough to read this:
how can I know if a PyObject_Call(...) or PyObject_GetAttr(...) returns a new
ref or a borrowed ref? I read online ( Python 3 ) that they are returning new
references. But does everyone comply with it? If so, it seems safe for me to
capture the return PyObject* into a wrapper class that automatically
Py_DECREF() upon destruction. But if not, what documentations should I refer to
for the behavior of a specific python module ( for example, matplotlib )?
This is the first time I ever checked out the Python C API, I guess I'm in need
of some conventions here. Your input is much appreciated.
The docs will say if it returns a new reference or a borrowed reference.
The general rule is that those functions that store an object in a
container, e.g. PyList_Append, will incref in order to retain the
object, but there are a few, such as PyList_SetItem, which don't incref,
but instead "steal" the reference.
A careful read of the docs is always advised. There's an occasional
exception!
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/JRFKJX3CSBJPORRZ7ODSF4C56VG33QLO/
Code of Conduct: http://python.org/psf/codeofconduct/