Python C Extensions
python at mrabarnett.plus.com
Thu Feb 24 12:46:29 EST 2011
On 24/02/2011 16:46, aken8062 at yahoo.com wrote:
> Thank you very much, it worked.
> I thought the PyDict_SetItem should assume ownership
> of the passed object and decrease it's reference count (I do not know
> Does this also go for the Lists ? Should anything inserted into list
> be DECRED-ed ?
> Thank you again for reply.
The pattern is that calls which create an object will return that
object with a refcount of 1, and calls which 'store' an object, for
example, PyDict_SetItem(...) and PyList_Append(...) will increment the
refcount of the stored object to ensure that it won't be garbage
When in doubt, try stepping through the code in a debugger. You'll see
that storing an object will cause its refcount to be incremented.
More information about the Python-list