The underlying implementation of Python’s list type is a bit different. Instead of several separate nodes referencing each other, a list is basically a single, contiguous slab of memory—what is usually known as an array. This leads to some important differences from linked lists. For example, while iterating over the contents of the list is equally efficient for both kinds (except for some overhead in the linked list), directly accessing an element at a given index is much more efficient in an array.
- Chapter 2: The Basics
- from Python Algorithms: Mastering Basic Algorithms in the Python Language, Second Edition
- Publisher: Apress
- Released: September 2015
Python maintains an array of references for fast indexing. List just stores references to objects on the heap. So the size of each element in list is the same.
Share this highlighthttp://www.safaribooksonline.com/a/python-algorithms-mastering/9424640/