views:

210

answers:

1

How are lists in python stored internally? Is it an array? A linked list? Something else?

Or does the interpreter guess at the right structure for each instance based on length, etc.

If the question is implementation dependent, what about the classic CPython?

+16  A: 

from Core Python Containers: Under the Hood
List Implementation:
Fixed-length array of pointers
* When the array grows or shrinks, calls realloc() and, if necessary, copies all of the items to the new space
source code: Include/listobject.h and Objects/listobject.c
btw: here is the video or here

sunqiang