[Numpy-discussion] ising model: f2py vs cython comparison

Pearu Peterson pearu at cens.ioc.ee
Sun Dec 23 05:52:16 EST 2007


On Sun, December 23, 2007 3:29 am, Ondrej Certik wrote:
> Hi,
>
> I need to write 2D Ising model simulation into my school, so I wrote
> it in Python, then rewrote it in Fortran + f2py, and also Cython:
>
> http://hg.sharesource.org/isingmodel/
>
> And Cython solution is 2x faster than f2py. I understand, that I am
> comparing many things - wrappers, my fortran coding skills
> vs Cython C code generation and gcc vs gfortran. But still any ideas
> how to speed up fortran+f2py solution is very welcomed.

When using g77 compiler instead of gfortran, I get a speed
up 4.8 times.

Btw, a line in a if statement of the fortran code
should read `A(p(i,j,N)) = - A(p(i,j,N))`.

Pearu




More information about the NumPy-Discussion mailing list