EEMI

Guided Notes

Copy vs View & Iterating

When arrays share memory, the base attribute, and looping with nditer and ndenumerate.

Copies and views

Slide 1 / 5

Some operations create a copy โ€” a new array with its own data. Others create a view โ€” a new array object that looks at the same data as the original.

โ€ข A copy owns its data: changing it never affects the original. โ€ข A view doesn't own its data: changing the view changes the original, and vice versa.

Views make NumPy fast and memory-efficient, because slicing a huge array doesn't duplicate it. But they can surprise you.

โ† Indexing & Slicing