Can we make Python fast without sacrificing readability? numba for Astrodynamics
2019-09-05 , Track 2 (Baroja)

There are several solutions to make Python faster, and choosing one is not easy: we would want it to be fast without sacrificing its readability and high-level nature. We tried to do it for an Astrodynamics library using numba. How did it turn out?


We are lucky there are very diverse solutions to make Python faster that have been in use for a while: from wrapping compiled languages (NumPy), to altering the Python syntax to make it more suitable to compilers (Cython), to using a subset of it which can in turn be accelerated (numba). However, each of these options has a tradeoff, and there is no silver bullet.

poliastro is a library for Astrodynamics written in pure Python. All its core algorithms are accelerated with numba, which allows poliastro to be decently fast while having minimal code complexity and avoid using other languages.

However, even though numba is quite mature as a library and most of the Python syntax and NumPy functions are supported, there are still some limitations that affect its usage. In particular, we strive to offer a high-level API with support for physical units and reusable functions which can be passed as arguments, which sometimes require using complex objects or introspective Python behavior which is not available.

In this talk we will discuss the strategies and workarounds we have developed to overcome these problems, and what advanced numba features we can leverage.


Project Homepage / Git:

https://github.com/poliastro/poliastro/

Abstract as a tweet:

Can we make Python fast without sacrificing readability? numba for Astrodynamics

Python Skill Level:

professional

Domain Expertise:

none

Domains:

none of the above

Juan Luis Cano is an Aerospace Engineer based in Barcelona, Spain working as a Software Engineer at Satellogic, where he develops Python tools for geospatial data processing and scheduling algorithms for satellite operations. He also freelances for R&D Aerospace companies and Business schools, and in his spare time he contributes to open source, chairs Python España non-profit, rides his bicycle, listens to '70s British Hard Rock, and pursues impossible dreams.