Search⌘ K

Views and Copies

Explore the key concepts of views and copies in NumPy arrays to understand how memory is shared or duplicated during array operations. Learn the impact of direct and fancy indexing, the use of ravel and flatten functions, and how temporary copies affect performance. This lesson helps optimize numerical computations by mastering array memory handling.

Views and copies are important concepts for the optimization of your numerical computations. Even if we’ve already manipulated them in the previous section, the whole story is a bit more complex.

Direct and indirect access

While executing a numpy instruction, either a copy of the input array is created or a view is provided. When the contents are physically stored in another location, it is called Copy. If on the other hand, a different view of the same memory content is provided, we call it View.

Indexing and Fancy Indexing

...