On 24 December 2016 at 19:25, Russell Jones <russell.jo...@gmail.com> wrote:
> > On 24 December 2016 at 17:39, Mikhail V <mikhail...@gmail.com> wrote: > >> The problem is however, transpose adds overhead, ca. 10-15% performance >> hit, > > Have you played with order='FORTRAN'? See > https://docs.scipy.org/doc/numpy/reference/generated/numpy.isfortran.html > I personally have'nt used "Fortran" order in arrays, and the perfromance for the case I have tested does not respond to the order of axes, but it shows that applying transpose to array is not a cheap operation and I should avoid it in the main loop. But I have played a lot with surface.get_buffer() to find out what is actually stored in the surface. So for 32 bit surface it turned out that pixels are stored in BGRA format and in "C" axes order, of course if one assumes that nothing else gets in the way during data copying. And for surfarray: tmp = pygame.surfarray.pixels2d(some_surface) print numpy.isfortran(tmp) Returns "True", so it is indeed "FORTRAN" order. And that is the main point here, probably this should not be so, and all those Surfarray/pixelcopy methods should correspond the "C" order? Just to avoid confusion by those familiar with numpy and additional operations. Probably there is more criterias here that I am not aware of and objective arguments to prefer "FORTRAN" order, apart from having more traditional [x,y] notation? Mikhail