[Numpy-discussion] Reversing an array in-place

Charles R Harris charlesr.harris@gmail....
Mon Dec 20 15:15:25 CST 2010


On Mon, Dec 20, 2010 at 1:25 PM, Justin Peel <jpscipy@gmail.com> wrote:

> I noticed that there is currently no way to reverse a numpy array
> in-place. The current way to reverse a numpy array is using slicing,
> ala arr[::-1]. This is okay for small matrices, but for really large
> ones, this can be prohibitive. Not only that, but an in-place reverse
> is much faster than slicing. It seems like a reverse method could be
> added to arrays that would reverse the array along a given axis fairly
> easily. Is there any opposition to this?
>
>
The reversed matrix is a view,  no copyihg is done. It is even faster than
an inplace reversal.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20101220/41cb8f0c/attachment.html 


More information about the NumPy-Discussion mailing list