releasing the reference returned by PyLong_FromLong, PyString_FromString & friends

grbgooglefan ganeshborse at gmail.com
Thu Dec 13 06:50:09 EST 2007


I am having a object tuple created at application startup. This tuple
I pass on to a python function in call to:
PyObject_CallObject(pcatInfo->pPyEvalFunction,pTuple);

For setting the values in this tuple, I am using PyLong_FromLong,
PyString_FromString & friends functions.
    PyTuple_SetItem(pTuple,nCtr,PyString_FromString(szOrdValue));

My worry is that I will be doing this operation lot many times in the
active duration of my application. During this time I do not want to
delete the tuple (pTuple) object passed to PyObject_CallObject, to
avoid the time taken for creating the object every time.

But this poses another problem. Every call I make to PyLong_FromLong,
PyString_FromString & friends & functions, they return references.
How do we release the references or objects returned by these
functions?
What is the optimum strategy in this?
Please guide.



More information about the Python-list mailing list