Woltan - 6 months ago 45

Python Question

I am using quite a lot of fortran libraries to do some mathematical computation. So all the arrays in numpy need to be *Fortran-contiguous*.

Currently I accomplish this with numpy.asfortranarray().

My questions are:

- Is this a fast way of telling numpy that the array should be stored in fortran style or is there a faster one?
- Is there the possibility to set some numpy flag, so that every array that is created is in fortran style?

Answer

Use optional argument order='F' (default 'C'), when generating numpy.array objects. This is the way I do it, probably does the same thing that you are doing. About number 2, I am not aware of setting default order, but it's easy enough to just include order optional argument when generating arrays.