Adding Cython to SciPy
As written on the Cython website:
Cython is an optimising static compiler for both the Python programming language and the extended Cython programming language (based on Pyrex). It makes writing C extensions for Python as easy as Python itself.
If your code currently performs a lot of loops in Python, it might benefit from compilation with Cython. This document is intended to be a very brief introduction: just enough to see how to use Cython with SciPy. Once you have your code compiling, you can learn more about how to optimize it by reviewing the Cython documentation.
There are only two things you need to do in order for SciPy compile your code with Cython:
Include your code in a file with a
.pyxextension rather than a.pyextension. All files with a.pyxextension are automatically converted by Cython toor files when SciPy is built.