InterviewSolution
Saved Bookmarks
| 1. |
How is memory allocated to a list in Python? |
|
Answer» A list in Python is an array that contains elements (pointers to objects) of a specific size only and this is a common feature of all dynamically typed languages. For the implementation of a list, a contiguous array of references to other objects is used. Python keeps a pointer to this array and the array’s length is stored in a list head structure. This makes indexing of a list independent of the size of the list or the value of the index. When items are appended or inserted, the array of references is resized. |
|