EuroSciPy logo

EuroSciPy 2013

Brussels, Belgium - August 21-24 2013

Benchmarking Several Python Compilers and Interpreters on Mathematical Applications

Pierrick Brunet , Serge Guelton


Serge Guelton(1,2), Pierrick Brunet(2) and Alan Raynaud(2)

(1) ENS ULM, Paris, France
(2) Télécom Bretagne, Plouzané, France

The Python language makes it easy to code in a few lines the solution to various mathematical problems. thanks to the Scipy module, it is also a valuable option for scientific computations. However, Python does not shine from its outstanding performance, which can quickly become a limitation and motivate a change for statically compiled languages. In addition to writing native modules, several compilation approaches have been proposed: using a hybrid C/Python language like in Cython, translate Python to C++ like in Shedskin, Nuitka or Pythran, or JIT compilation like PyPy of Numba.

These compilers are of great interest for the Python programmers has they make it possible to keep the advantage of high level programming while still getting reasonable performances. Based on the motto that it is costly to maintain two versions of a code, this study focuses on compilers that do not break compatibility with the standard interpreter: Shedskin, Nuitka, Pythran and Pypy, using CPython as a base reference.

This study is based on two code bases supposedly representative of mathematical applications: the Euler Project and Rosetta Code. The Euler Project is a suite of 200 mathematical problems, many of which have been solved in Python and published online. Rosetta Code is a code database in the form of a wiki where contributers can provide the solution to various mathematical or computer science challenges in their language of choice.

The analyse of the performance of the code generated/interpreted by the considered compilers provides valuable insight to their user, as it helps to understand the performance impact of various construct depending on the tool used, and to these tool developers, to drive future developments.