Embedding Python in C++ application: Question #1

Russell Turpin russell_turpin at hotmail.com
Tue Dec 4 18:34:12 CET 2001

Mark Hammond <MarkH at ActiveState.com> wrote in message news:<3C0C3B3E.9030302 at ActiveState.com>...
> Py_BuildValue is a convenience function.

OK. I'm finding the relevant interfaces in Python/C API.
Do I read this right, that all new objects are created 
with a refcount of 1 , so that a called function
can pass them to the caller without ref-count manipulation?
Thus, I can call PyList_New() to create the list that will
be returned to the calling Python procedure, iteratively
pass the results of PyTuple_New() directly to 
PyList_SetItem(), which "steals" the reference to the 
tuple, and then return the list, all without a single 
INCREF or DECREF? Which, of course, is the way it *ought* 
to work, and that seems to be what it says .. 


More information about the Python-list mailing list