NumPy TutorialLesson 8Free preview
NumPy Copy vs View
This lesson is part of NumPy · All levels
Summary
The key difference in NumPy is between copying and viewing. Copy creates a new array object with its own data, whereas view only points to the memory block belonging to the original array. Changes to the view will change the original array, while changes to the copy will not affect.
Key points
- View shares data with the original array so that changes in one affect the other.
- The copy has its own data so it's independent of the original array.
- Slicing by default produces views, not copies.
- The base attribute indicates whether the array is a view (base instead of None).
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.