Understanding Numba - the Python and Numpy compiler

Christoph Deil

CPython Compiler and Interpreters Multi-Threading Performance Scientific Libraries (Numpy/Pandas/SciKit/...)

Do you have numerical code written in Python and Numpy? Do you wish it ran faster, using the full potential of your CPU?

Then you should try Numba, a JIT compiler that translates a subset of Python and Numpy code into fast machine code.

This talk will explain how Numba works, and when and how to use it for numerical algorithms, focusing on how to get very good performance on the CPU.

To understand this talk, only a basic knowledge of Python and Numpy is needed.

You will learn how Python compiles functions to bytecode and how Numba compiles bytecode to machine code. Why algorithms implemented using Numpy sometimes don't yield great performance, and how to do better using Numba. You will learn about the @numba.jit and @numba.vectorize decorators and how to create functions that use the CPU well by using e.g. multi-threading (several CPU cores), vector instructions (single instruction multiple data) and fast math (trade float accuracy for speed).

You will also learn when it does and doesn't make sense to use Numba, by contrasting it briefly with some other options for high-performance computing from Python: PyPy, C, C++, Cython, Numexpr, Dask, PyTorch, Tensorflow and Google JAX

Type: Talk (30 mins); Python level: Intermediate; Domain level: Beginner

Christoph Deil

MPIK

I am a researcher in gamma-ray astronomy working at the Max-Planck-Institute for Nuclear Physics in Heidelberg, Germany. I've been using Python and scientific Python packages since 2007. I am developing an open-source Python package for gamma-ray astronomy (https://gammapy.org) and am contributing to several other codes on Github. You can find more information and my contact information at https://christophdeil.com .