NumPy Crash Course: Array Basics
Lists vs. Arrays We’re all familiar with the standard Python list — a mutable object that has great flexibility in that not all elements of the list need to be of a homogeneous data type. That is, you can have a list containing integers, strings, floats, and even other objects. my_list = [2, {'dog': ['Rex', 3]}, 'John', 3.14] The above is a perfectly valid list containing multiple data types as elements — even a dictionary which contains another list! However, to support all these simultaneous data types, each Python list element must contain its own unique information. Each element acts as a pointer to a unique Python Object. Because of this inefficiency, it becomes much more taxing to use lists as they grow larger and larger. >>>for element in my_list: print(type(element)) <class 'int'> <class 'dict'> <class 'str'> <class 'float'> With an array, we do away with the flexibility o