I'm trying to get the Py_INCREF
's and Py_DECREF
's for my c extension right.
Whilst doing so I've been stumbling about really high values for generators. What I've
been doing is the following:
// Forgive me for leaving out the NULL checks
PyObject *get_generator = PyUnicode_InternFromString("get_generator");
PyObject *callback;
PyObject *seq;
PyObject *item;
callback = PyObject_CallMethodObjArgs(parent->state, get_generator, NULL);
seq = PyObject_GetIter(tmp);
Py_DECREF(callback);
while ((item = PyIter_Next(seq))) {
...
Code
...
Py_DECREF(item);
}
Py_DECREF(seq);
printf("!!!%zd\n", seq);
Can somebody explain please.