Numba is an open source JIT compiler that translates a subset of Python and NumPy code into fast machine code.
Numba makes Python code fast Numba is an open source JIT compiler that translates a subset of Python and NumPy code into fast machine code. Learn More Try Numba »
Numba documentation ¶ This is the Numba documentation. Unless you are already acquainted with Numba, we suggest you start with the User manual.
A ~5 minute guide to Numba ¶ Numba is a just-in-time compiler for Python that works best on code that uses NumPy arrays and functions, and loops. The most common way to use Numba is through its collection of decorators that can be applied to your functions to instruct Numba to compile them.
Starting with numba version 0.12, it is possible to use numba.jit without providing a type-signature for the function. This functionality was provided by numba.autojit in previous versions of numba. The old numba.autojit hass been deprecated in favour of this signature-less version of numba.jit.
Installing Numba from source is fairly straightforward (similar to other Python packages), but installing llvmlite can be quite challenging due to the need for a special LLVM build. If you are building from source for the purposes of Numba development, see Build environment for details on how to create a Numba development environment with conda.
Numba understands NumPy arrays ¶ NumPy arrays are understood by numba. By using the numba.typeof we can see that numba not only knows about the arrays themshelves, but also about its shape and underlying dtypes:
Parallel Range ¶ Numba implements the ability to run loops in parallel, similar to OpenMP parallel for loops and Cython’s prange. The loops body is scheduled in seperate threads, and they execute in a nopython numba context. prange automatically takes care of data privatization and reductions: