[Numpy-discussion] Change default order to Fortran order

Matthew Brett matthew.brett at gmail.com
Mon Aug 3 12:24:51 EDT 2015


On Mon, Aug 3, 2015 at 5:01 PM, Sturla Molden <sturla.molden at gmail.com> wrote:
> Matthew Brett <matthew.brett at gmail.com> wrote:
>
>> Sure, but to avoid confusion, maybe move the discussion of image
>> indexing order to another thread?
>>
>> I think this thread is about memory layout, which is a different issue.
>
> It is actually a bit convoluted and not completely orthogonal. Memory
> layout does not matter for 2d ndexing, i.e. (x,y) vs. (row, column), if you
> are careful when iterating, but it does matter for Nd indexing. There is a
> reason to prefer (x,y,z,t,r) in column major order or (recording, time,
> slice, row, column) in row major order. Otherwise you can get very
> inefficient memory traversals. Then if you work with visualization
> libraries that expects (x,y,z) and column major order, e.g. ITK, VTK and
> OpenGL, this is really what you want to use. And the choise of indexing
> (x,y,z) cannot be seen as independent of the memory layout. Remember, it is
> not just a matter of mapping coordinates to pixels. The data sets are so
> large in MRI processing that memory layout does matter.

I completely agree that memory layout can affect performance, and this
can be important.

On the other hand, I think you agree that the relationship of axis
order to memory layout is just a matter of mapping coordinates to
pixels.

So you can change the axis ordering without changing the memory layout
and the memory layout without changing the axis ordering.

Of course you could argue that it would be simpler to fuse the two
issues, and enforce one memory layout - say Fortran.    The result
might well be easier think about, but it wouldn't be much like numpy,
and it would have lots of performance and memory disadvantages.

Cheers,

Matthew



More information about the NumPy-Discussion mailing list