Answer the question
In order to leave comments, you need to log in
What data structure stores containers* (list, turple) in Python* 3.x (Cpyhtoh)?
Interested in what form list and turple are stored in memory under the hood in Python (Cpyhtoh)?
3 basic structural data are suitable for its storage:
1. Array - elements in it are stored sequentially in memory, that is, the array element index usually indicates how many slots from the beginning of the array a particular element is located.
2. Singly linked list - elements can no longer be stored sequentially, since the current element has a pointer to the next element of the singly linked list.
3. Doubly linked list - it is similar to a singly linked list, but in addition to the pointer to the next element, there is also a pointer to the previous one.
In some articles ( https://pythonz.net/references/named/slozhnost-ope...) specifies that list is stored as an array. In general, this type is quite good for itself, since in this case access for random reading of an element is provided quickly, + one data type is stored in the array itself (if I'm not mistaken, a pointer to a PyObject reference, which in turn can be absolutely of any type ( int, bool, str, list, set, ...)).
Is this true? If so, does this rule also apply to turple?
Answer the question
In order to leave comments, you need to log in
Relevant section of the documentation . Implementation source code .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question