S
Simon Dahlbacka
I'm making a C extension where I'm wrapping a C function like follows
void MyFunction(/*[in,out]*/ ArrayType array)
to
a python function taking a list as inparameter and returning a list (for
consistency with other pointer arguments)
Now to the question..
I'm a little confused about the reference counting..
static PyObject* MyFunction(PyObject * /*self*/, PyObject *args) {
PyObject *list;
PyArg_ParseTuple(args, &PyList_Type, &list);
//do stuff with list elements
// XXX do I need Py_INCREF(list); here ???
return list;
}
obviously error checking is omitted for brevity.
PS. are there any documentation explaining the reference counting issues in
more detail than the docs @ python.org ?
void MyFunction(/*[in,out]*/ ArrayType array)
to
a python function taking a list as inparameter and returning a list (for
consistency with other pointer arguments)
Now to the question..
I'm a little confused about the reference counting..
static PyObject* MyFunction(PyObject * /*self*/, PyObject *args) {
PyObject *list;
PyArg_ParseTuple(args, &PyList_Type, &list);
//do stuff with list elements
// XXX do I need Py_INCREF(list); here ???
return list;
}
obviously error checking is omitted for brevity.
PS. are there any documentation explaining the reference counting issues in
more detail than the docs @ python.org ?