[Numpy-discussion] Slicing/selection in multiple dimensions simultaneously

David Warde-Farley dwf at cs.toronto.edu
Mon Mar 2 05:19:18 EST 2009


On 28-Feb-09, at 12:27 PM, Jonathan Taylor wrote:

> This does seem like the only way to write this nicely.  Unfortunately,
> I think this may be wasteful memory wise (in contrast to what the
> obvious matlab code would do) as it constructs an array with the whole
> first index intact at first.

True enough, though if I understand correctly, this is only a _view_  
onto the original array, and nothing is immediately copied. So it does  
waste memory creating a view and then a view on the view, but I don't  
think it's proportional to the size of the returned array.

Maybe Robert or someone else can confirm this.

David



More information about the NumPy-Discussion mailing list