From Numpy Internals:
NumPy arrays consist of two major components, the raw array data (from now on, referred to as the data buffer), and the information about the raw array data.
in the case of slicing z = x[:]
, it is a view, NumPy stores the significant set of data that describes how to interpret the data in the data buffer at the different memory location but it can share elements from z
, hence both have different id and hence False
.
>>> x = np.array([1, 2, 3, 4, 5])
>>> z = x[:] # same as x.view()
>>> x[2]
3
>>> x[2] = 1
>>> x
array([1, 2, 1, 4, 5])
>>> z
array([1, 2, 1, 4, 5])
>>> x is z
False
If you modify x
, z
will be also modified.
More reference at Numpy Documentation