By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,100 Members | 2,846 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,100 IT Pros & Developers. It's quick & easy.

Int tuple element scope

P: n/a
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
Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.