I'll probably rewrite that paragraph, since the main point is to tell people unfamiliar with Python that lists aren't actually linked lists.
I'll probably rewrite that paragraph, since the main point is to tell people unfamiliar with Python that lists aren't actually linked lists.
And when the list needs to be resized and doubles itself, it's just doubling the space for object references?
Yes. Every Python object is held by the interpreter as a pointer to a PyObject struct on the (C) heap.
func = ctypes.cast(int(address), ctypes.py_object).value
Was kinda cool actually seeing that work.Yep, it is an array of pointers: https://github.com/python/cpython/blob/3.7/Include/listobjec...
> And when the list needs to be resized and doubles itself, it's just doubling the space for object references?
Basically yes. The growth pattern is not as aggressive as doubling though: https://github.com/python/cpython/blob/3.7/Objects/listobjec...
Thanks for sharing these links.
"The growth pattern is: 0, 4, 8, 16, 25, 35, 46, 58, 72, 88, ..."
What is the big-o amortized cost of using this pattern? Doubling has a easy proof that it's O(1) amortized.