Pyccel: a Python-to-X transpiler for scientific high-performance computing
Emily Bourne, Yaman Güçlü, Said Hadjout, Ahmed Ratnani · The Journal of Open Source Software · 2023
The Python programming language has gained significant popularity in scientific computing and data science, mainly because it is easy to learn and provides many scientific libraries, including parallel ones.While these libraries are very fast, they are usually written in compiled languages such as Fortran and C/C++.User code written in pure Python is usually much slower; because Python is a dynamically typed language which introduces overhead in many basic operations.Due to this limitation, one often needs to rewrite the computational parts of their Python code in a statically typed language to take full advantage of optimization and acceleration techniques.This expensive process happens naturally during the transition from a prototype to a production code, which is the principal bottleneck in scientific computing.We believe that such a bottleneck can be resolved, or at least drastically reduced, through the use of automatic code generation tools.In this work we present Pyccel, a Python library which acts as a transpiler by translating Python code to either Fortran or C code, and as an accelerator by making the generated code callable from Python once again.Not only is the Pyccel-generated Fortran or C code very fast, but it is human-readable; hence an expert programmer can easily profile the code on the target machine and further optimize it.Pyccel provides a variety of methods for the efficient usage of the available hardware resources, such as type annotations, function decorators, and OpenMP pragmas.Moreover, Pyccel allows the user to link their code to external libraries written in the target language.