Authors: Guelton, Serge, ENS ; Brunet, Pierrick, Télécom Bretagne ; Raynaud, Alan, Télécom Bretagne; Adrien Merlini, Télécom Bretagne; Mehdi Amini, SILKAN
Pythran is a young open source static compiler that turns Python modules into native ones. Based on the fact that scientific modules do not rely much on the dynamic features of the language, it trades them against powerful, eventually inter procedural, optimizations, such as:
automatic detection of pure functions; temporary allocation removal; constant folding; numpy ufunc fusion and parallelisation; explicit parallelism through OpenMP annotations; false variable polymorphism pruning; AVX/SSE vector instruction generation. In addition to these compilation steps, Pythran provides a C++ runtime that leverages on the C++ STL for generic containers, and the Numeric Template Toolbox (nt2) for numpy support. It takes advantage of modern C++11 features such as variadic templates, type inference, move semantics and perfect forwarding, as well as classical ones such as expression templates.
The input code remains compatible with the Python interpreter, and output code is generally as efficient as the annotated Cython equivalent, if not more, without the backward compatibility loss. Numpy expressions runs as fast as if compiled with numexpr, without change on the original code.