There are precise rules on which slices will return views and which ones will return copies. Only basic slices (mainly index expressions with :) return views, whereas any advanced selections (such as slicing with a Boolean) will return a copy of the data. For instance, it is possible to create new matrices by indexing with lists (or arrays):
a = arange(4) # array([0.,1.,2.,3.]) b = a[[2,3]] # the index is a list [2,3] b # array([2.,3.]) b.base is None # True, the data was copied c = a[1:3]
c.base is None # False, this is just a view
In the preceding example, the array b is not a view, whereas the array c, obtained with a simpler slice, is a view.
There is an especially simple slice of an array that returns a view of the whole array:
N = M[:] # this is a view of the whole array M