View
When a new array is created after some operation on existing numpy array, a view is created which points to the same raw array data (data buffer).
Some operation returns view and some returns array pointing to whole new data buffer.
It increase the performance of numpy as no new data is getting created.
However, it has some implications as shown below.
a = np.arange(5)
#array([0, 1, 2, 3, 4])
b = a[:2]
#array([0, 1])
a[0] = 133
#array([133, 1, 2, 3, 4])
b
# array([133, 1])
So, changing the view modifies the original data buffer.
np.may_share_memory()
can be used to verify if two arrays share the same memory buffer.
np.may_share_memory(a, b)
# True