<div dir="ltr">I noticed today that the documentation for np.transpose states, for the return value, that "A view is returned whenever possible."<div><br></div><div>Is there really any situation where swapping axes around could trigger the need to copy data, or will a view always be returned no matter what?</div>
<div><br></div><div>I can't think of any such situation, and was planning on relying on that for some code: basically, I have an output array, which I would like to be contiguous. So I preallocate it with the right shape, then take a view of it moving a certain axis to the end to make computations easier, run all my computations on the modified view, then return the original array, not the view.</div>
<div><br></div><div>If I started with an array with the axis at the end, and then transposed it, I would need to make a copy to make it contiguous, which is what I am trying to avoid.</div><div><br></div><div style>Is this a bad practice? Is that precaution in the documentation real? Should I check that my view's base is the original array and trigger a copy, or is it an unnecessary check?</div>
<div style><br></div><div style>Thanks in advance,</div><div style><br></div><div style>Jaime</div><div><br></div><div>
-- <br>(\__/)<br>( O.o)<br>( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes de dominación mundial.
</div></div>