R
Ron Griswold
Can anyone tell me why the following will cause the returned tuple elements to remain un collected when the tuple goes out of scope:
PyObject * iobj = PyObject_New( PyIntObject, &PyInt_Type );
iobj->ob_ival = val;
PyTuple_SetItem( tuple, index, iobj );
return tuple;
while the following will collect the elements:
PyTuple_SetItem( tuple, index PyInt_FromLong( val ) );
return tuple;
both PyObject_New and PyInt_FromLong return new references and I have verified that in all cases the refcount upon return is 1 for all objects involved. So I'm just wondering if I'm missing something fundamental.
Thanks in advance!
Ron
PyObject * iobj = PyObject_New( PyIntObject, &PyInt_Type );
iobj->ob_ival = val;
PyTuple_SetItem( tuple, index, iobj );
return tuple;
while the following will collect the elements:
PyTuple_SetItem( tuple, index PyInt_FromLong( val ) );
return tuple;
both PyObject_New and PyInt_FromLong return new references and I have verified that in all cases the refcount upon return is 1 for all objects involved. So I'm just wondering if I'm missing something fundamental.
Thanks in advance!
Ron