[Numpy-discussion] Reversing an array in-place

Justin Peel jpscipy at gmail.com
Mon Dec 20 17:36:17 EST 2010


Oh, you're quite right. I should have looked more closely into this.
Thanks for the reply.

On Mon, Dec 20, 2010 at 2:15 PM, Charles R Harris
<charlesr.harris at gmail.com> wrote:
>
>
> On Mon, Dec 20, 2010 at 1:25 PM, Justin Peel <jpscipy at 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
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>



More information about the NumPy-Discussion mailing list