Numba

Last updated
Original author(s) Continuum Analytics
Developer(s) Community project
Initial release15 August 2012;13 years ago (2012-08-15)
Stable release
0.61.2 [1]   OOjs UI icon edit-ltr-progressive.svg / 9 April 2025;5 months ago (9 April 2025)
Repository
Written in Python, C
Operating system Cross-platform
Platform x86-64, ARM64, POWER
Type Technical computing
License BSD 2-clause
Website numba.pydata.org
Numba CUDA
Developer(s) NVIDIA
Stable release
0.4.0 / January 27, 2025;7 months ago (2025-01-27) [2]
Repository github.com/NVIDIA/numba-cuda
Platform NVIDIA GPU
License BSD 2-clause
Website nvidia.github.io/numba-cuda/

Numba is an open-source JIT compiler that translates a subset of Python and NumPy into fast machine code using LLVM, via the llvmlite Python package. It offers a range of options for parallelising Python code for CPUs and GPUs, often with only minor code changes.

Contents

Numba was started by Travis Oliphant in 2012 and has since been under active development with frequent releases. The project is driven by developers at Anaconda, Inc., with support by DARPA, the Gordon and Betty Moore Foundation, Intel, Nvidia and AMD, and a community of contributors on GitHub.

Example

Numba can be used by simply applying the numba.jit decorator to a Python function that does numerical computations:

importnumbaimportrandom@numba.jitdefmonte_carlo_pi(n_samples:int)->float:"""Monte Carlo"""acc=0foriinrange(n_samples):x=random.random()y=random.random()if(x**2+y**2)<1.0:acc+=1return4.0*acc/n_samples

The just-in-time compilation happens transparently when the function is called:

>>> monte_carlo_pi(1000000)3.14

GPU support

Numba can compile Python functions to GPU code. Initially two backends are available:

Since release 0.56.4, [3] AMD ROCm HSA has been officially moved to unmaintained status and a separate repository stub has been created for it.

Alternative approaches

Numba is one approach to make Python fast, by compiling specific functions that contain Python and NumPy code. Many alternative approaches for fast numeric computing with Python exist, such as Cython, Pythran, and PyPy.

References

  1. "Release Numba 0.61.2". 9 April 2025. Retrieved 24 April 2025.
  2. "Tags · NVIDIA/numba-cuda" . Retrieved February 16, 2025.
  3. "Release Notes — Numba 0.56.4+0.g288a38bbd.dirty-py3.7-linux-x86_64.egg documentation".