[Yt-dev] Auto-cythonize your code

Matthew Turk matthewturk at gmail.com
Wed Aug 26 13:39:07 PDT 2009


  Hi guys,

Just as a note, if you're doing heavily performance-intensive stuff,
you can use the latest version of Cython to auto-cythonize (i.e.,
compile down to C) your code.  This requires you have Cython > 0.11.2
or so installed.

http://docs.cython.org/docs/tutorial.html#pyximport-cython-compilation-the-easy-way

At the top of your script using yt, put this line:

import pyximport; pyximport.install(pyimport=True)

And it'll try compiling to C all of your code before executing.
Without annotations, speedups of 10-30% have been reported.
Currently, even after hacking out the "exec" calls, it doesn't work
with yt ... but I'm going to play with this some more later.

-Matt



More information about the yt-dev mailing list