How is Python's List Implemented?

后端 未结 9 875
野趣味
野趣味 2020-11-22 08:00

Is it a linked list, an array? I searched around and only found people guessing. My C knowledge isn\'t good enough to look at the source code.

9条回答
  •  萌比男神i
    2020-11-22 08:42

    This is implementation dependent, but IIRC:

    • CPython uses an array of pointers
    • Jython uses an ArrayList
    • IronPython apparently also uses an array. You can browse the source code to find out.

    Thus they all have O(1) random access.

提交回复
热议问题