When to use Py_INCREF(x) and Py_DECREF(x)
Opinderjit
bhellao at my-deja.com
Wed Oct 25 10:38:24 EDT 2000
I am confused with when to use Py_INCREF(x) and Py_DECREF(x). In the
following example, I am creating a dictionary object, populating it,
and returning it back to Python. Should I use Py_INCREF(dict) to
increase the dictionary object's reference count?
Thanks.
PyObject *dict; // Metadata dictionary
dict = PyDict_New();
while (pos != NULL)
{
...
// Name is a string
// Value is a string
PyDict_SetItemString(dict, Name, PyString_FromString(Value));
delete Name;
}
return dict;
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list