Why PyList_Append is called each time a list is evaluated?

I’m working with CPython3.11.0a3+. I added a break point at PyList_Append and modified the function to stop when the newitem is a dict. The original function: int PyList_Append(PyObject *op, PyObject *newitem) { if (PyList_Check(op) && (newitem != NULL)) return app1((PyListObject *)op, newitem); PyErr_BadInternalCall(); return -1; } Modified version: int PyList_Append(PyObject *op, PyObject *newitem) { if… Read More Why PyList_Append is called each time a list is evaluated?

Why PyList_Append is called each time a list is evaluated?

I’m working with CPython3.11.0a3+. I added a break point at PyList_Append and modified the function to stop when the newitem is a dict. The original function: int PyList_Append(PyObject *op, PyObject *newitem) { if (PyList_Check(op) && (newitem != NULL)) return app1((PyListObject *)op, newitem); PyErr_BadInternalCall(); return -1; } Modified version: int PyList_Append(PyObject *op, PyObject *newitem) { if… Read More Why PyList_Append is called each time a list is evaluated?