Python's list structure is like below:
typedef struct {
PyObject_VAR_HEAD
PyObject **ob_item;
Py_ssize_t allocated;
} PyListObject;
Why using **ob_item? I think *ob_item is enough.
Python's list structure is like below:
typedef struct {
PyObject_VAR_HEAD
PyObject **ob_item;
Py_ssize_t allocated;
} PyListObject;
Why using **ob_item? I think *ob_item is enough.
Because, as with any list created using pointers, as you add and remove elements, you'll need to change what a node's pointer is pointing to, not just the value of the object being pointed to (which is what you would get with just *ob_item; **ob_item let's you "repoint" the pointer).
Remember, the list is not going to contain the actual objects, it contains pointers to them. To be able to use a pointer that points to a pointer (to, as I mentioned, be able to repoint the pointer for a node), you need **.