Returning objects to Python from C
问题 I've read the documentation for the Python C-API, and even written a few extension modules. However, I'm still a bit unclear on the exact semantics when it comes to returning Python objects from a C function. The limited examples in the Python docs usually show a C function which returns the result of Py_BuildValue . Now, Py_BuildValue returns a New Reference , and transfers ownership of this reference over to the interpreter. So, can I extrapolate from this that it is a general rule that any