13
इस रिसाव ?:क्या यह PyList_Append (सूची, Py_BuildValue (...)) रिसाव है?
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;
}
हालांकि, मैं, पहले लगता है यह यह करने के लिए बेहतर है, किसी भी मामले ?:
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;
}
मेरे संदेह की पुष्टि करने के लिए धन्यवाद! – James
पाइथन दस्तावेज कहां से मिलता है कि किसी को पता चलता है कि PyList_Append संग्रहित ऑब्जेक्ट का पुनर्वित्त बढ़ाता है? मैं कहीं भी नहीं देखता हूं। –