I have seen 2D arrays indexed in two different ways in Numpy. Assuming I have an array A, I can type A[0:3, 2:5] or A[0:3][:,2:5]. Either way, I get the same slice of A.
I am curious why one would choose one over the other. Are there speed differences? Or is one simply more Pythonic than the other?
The first form is more pythonic and desireable, since it performs one slice operation. The second form actually slices twice.
In the first form,
A[0:3]returns a slice that is smaller than A, then the second slice operation slices the result from the first slice one.