[Numpy-discussion] View on sliced array without copy

Nicolas Rougier Nicolas.Rougier@inria...
Tue Feb 12 11:53:17 CST 2013


I'm trying to get a view on a sliced array without copy but I'm not able to do it as illustrated below:

dtype = np.dtype( [('color', 'f4', 4)] )
Z = np.zeros(100, dtype=dtype)

print Z.view('f4').base is Z        # True
print Z[:50].base is Z              # True

print (Z.view('f4'))[:50].base is Z # False
print Z[:50].view('f4').base is Z   # False

Did I do something wrong or is it expected behavior ?


More information about the NumPy-Discussion mailing list