How does Python store lists internally?

后端 未结 1 2027
不知归路
不知归路 2020-12-29 07:57

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 base

相关标签:
1条回答
  • 2020-12-29 08:24

    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

    0 讨论(0)
提交回复
热议问题