numpy arrays

Nobody nobody at nowhere.invalid
Wed Mar 23 09:45:29 EDT 2016


> What you want is called *transposing* the array:
> 
> http://docs.scipy.org/doc/numpy/reference/generated/numpy.transpose.html
> 
> That should be a sufficiently fast operation.

Transposing itself is fast, as it just swaps the strides and dimensions
without touching the data (i.e. it returns a new view of the original
array), but subsequent operations may be slower as the data is no longer
contiguous (i.e. iterating over the flattened array in order won't result
in sequential memory access).

If that's an issue, you can use numpy.ascontiguousarray() to make a
contiguous copy of the data.




More information about the Python-list mailing list