Advertisements
Advertisements
Question
How are lists implemented in memory?
Short Answer
Advertisements
Solution
- A Python list is implemented as a
variable-length array. - It stores contiguous
references (pointers)to objects, not necessarily the objects themselves. - A list header stores a pointer to this reference array and its length.
- When an item is inserted or appended, Python may resize the array of references.
shaalaa.com
Is there an error in this question or solution?
