Programming FAQ for Python2 and Programming FAQ for Python3:
The
array
module also provides methods for creating arrays of fixed types with compact representations, but they are slower to index than lists.
To get an element of a list, we need an additional dereferencing; whereas the elements of array
are arranged much more compactly than list
and they are fixed type, why is it slower instead?
(Obviously, the Python developers have certain reasons to support this conclusion, otherwise they wouldn’t have documented it.)
The test code is provided by Stefan. (Thank you.)