Hi there,
I have been using Python for a while and recently have started to extend with C modules. I am a little confused about reference counting though. Suppose we have the following:
Code:
static PyObject *SomeFunction(PyObject *self, PyObject *args){
PyObject *storage_for_python_list;
if(!PyArg_ParseTuple(args, "O", &storage_for_python_list))
return NULL;
...do something with list
Py_INCREF(Py_None);
return Py_None;
do we need to Py_DECREF(storage_for_python_list)??
Second, is doing the following a bad idea?
Code:
Py_Object *list;
list= PyList_New(n);
PyList_SetItem(list, index, PyFloat_FromDouble(some_double_value));
I'm not sure what happens to the reference created from PyFloat_FromDouble in this case.
Thanks in advance for any suggestions/feedback.