What happens to the original numpy array when we slice it and set it to the same variable?
>>> a = np.arange(15).reshape([3,5])
>>> a
array([[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14]])
>>> a = a[2:,:]
>>> a
array([[10, 11, 12, 13, 14]])
What happened to the original a array, was it garbage collected? However, we need the original array to refer to, so where is it stored?
numpy) then it is reclaimed immediately when the ref count reaches 0. Note, the underlying buffer is not freed, since array-slices create views over the underlying buffer.aagain? Justb = a[2:, :]you have both the original and the outcome? Yes, if there are no further references to the original array, it will be garbage collected (in this case that means it will be around to provide the view - @juan.arrivillaga makes an important point).