[Numpy-discussion] Inplace reshape
Mon Apr 23 12:20:18 CDT 2007
On 23/04/07, Gael Varoquaux <firstname.lastname@example.org> wrote:
> I thought I remembered there was a way to reshape in-place an array, but
> neither google, nor greping my mailbox brings anything out.
> Am I wrong, or is there indeed a way to reshape in-place an array ?
Sometimes it's just impossible to reshape an array without copying.
But reshape() (either the method or the function) copies only the
array descriptor if that's possible. So you'll have a new ndarray
object, but the data will not be copied. Assigning to the shape
attribute might do what you want (if it triggers a reshape()
internally, which I think it does).
I don't think it's possible to *rearrange* the data in memory in
place. I can't even think of an algorithm to do that, off the top of
More information about the Numpy-discussion