grbgooglefan <ganeshbo...@gmail.com> writes: > Regarding PyTuple_New, when I pass this tuple with variable values > set to some evaluation function like PyObject_CallObject, do I need > to increment reference for this tuple & then decrement again after > the call returns?
You don't. It is assumed that you already own the reference to the tuple, so you can freely pass it to functions. When you're done with the tuple (such as when you're about to leave the C scope that holds the reference to it), you're suppose to decref it. If the function you call stores it somewhere, that function is responsible for incrementing its reference count. The exception to the above are functions documented to "steal" the reference count of their arguments, such as PyList_SetItem, but those are generally quite rare and always clearly documented. Maybe you should post a question to the capi-sig list explaining what you're trying to do; perhaps there's a better way to do it. For example, maybe you don't need to create a tuple and then call PyObject_CallObject, but simply use PyObject_CallFunction, which will create the tuple for you. -- http://mail.python.org/mailman/listinfo/python-list