efj at mintec.com
Tue Jun 19 20:00:51 CEST 2001
I am unclear about my responsibilities in refrence counting. I am
trying to use Python as an extension language. In the code snip below
I wish to return an "associative array"/"dictionary" of information.
Upon looking through the newsgroup I got a bit paranoid about memory
leaks due to incorrect reference counting. Do I need to decrement the
reference count for the second dictionary below (grades)? When I use
PyStringFromString() it creates the object with a reference count of
one, then it is added to my dictionary with PyDict_SetItem() does this
increment it again? Should I create it in a seperate step then use
PyDict_SetItem() and then decrement it?
Thanks in advance for any help.
int _PY_GetCutData(PyObject *self, PyObject *args)
PyObject *ret = NULL,
*grades = NULL;
ret = PyDict_New();
grades = PyDict_New();
for(i = 0 ; i < numg ; ++i)
if(i != numg)
More information about the Python-list