Does this leak?:
static PyObject* foo(PyObject* self, PyObject* args){
PyObect* list = PyList_New(0);
for(int i = 0; i < 100; i++)
// leak? does PyList_Append increment ref of the temporary?
PyList_Append(list, Py_BuildValue("i", 42));
return list;
}
Though, I suppose it's better to do this, in any case?:
static PyObject* foo(PyObject* self, PyObject* args){
PyObect* list = PyList_New(100);
for(int i = 0; i < 100; i++)
PyList_SetItem(list, i, Py_BuildValue("i", 42));
return list;
}