[SciPy-User] help speeding up a Runge-Kuta algorithm (cython, f2py, ...) (Sturla Molden) (Sturla Molden)
Sergio Rojas
sergio_r at mail.com
Mon Aug 6 09:51:23 EDT 2012
> Which version of Cython do you have (use at least 0.16).
> Sturla
I missed that. Now the full stuff compiles and runs:
>$ python -c "from Cython.Compiler.Version import version; print version"
0.16
>$ python runme.py
numpy_only: 3.5 sec
cythonized_numpy: 2.62 sec
cythonized_numpy_2: 4.15 sec
cythonized_numpy_2b: 3.35 sec
cythonized_numpy_3: 1.48 sec
cythonized_numpy_4: 1.18 sec
pointer_arith: 1.19 sec
memview: 1.22 sec
Sergio
************************************************************ Here is an example code of how to use Cython as a Fortran killer: https://github.com/sturlamolden/memview_benchmarks/blob/master/memview.pyx In this case, the performance with -O2 was just 2.2% slower than "plain C" with pointer arithmetics. It is possible to write very fast array code with Cython, but you must do it right. For comparison, this is very slow: https://github.com/sturlamolden/memview_benchmarks/blob/master/cythonized_numpy_2b.pyx What this mean is this: For anything but trivial code, the NumPy syntax is just too slow and should be avoided! I breiefly looked at the Cython code posted in this thread, and it suffers form all these issues. Sturla **********************************************
More information about the SciPy-User
mailing list