[capi-sig] DECREF when using PyDict_SetItem...
mail at timgolden.me.uk
Fri Jul 2 11:14:33 CEST 2010
I'm using PyDict_SetItemString to add a long from a C struct
into a Python dictionary. The full code is in the usn2dict
function in here:
but the sort of thing I'm talking about is this:
My understanding is that PyLong_FromLongLong passes its reference
to my function, which then passes it to PyDict_Set... which INCREFs
it. That means, I think, that my function should DECREF it before
exit since I'm only creating it to store it in the dict. Is that correct?
In other words, should my code really do this?
record_length = PyLong_FromLongLong (usn_record->RecordLength);
PyDict_SetItemString (dict, "RecordLength", record_length);
More information about the capi-sig