explaingit

numba/numba

11,020PythonAudience · researcherComplexity · 3/5LicenseSetup · moderate

TLDR

Numba speeds up Python numerical code by compiling it to machine code at runtime using LLVM, add one decorator to a function and it runs dramatically faster, with optional GPU and multi-core support.

Mindmap

mindmap
  root((numba))
    What it does
      JIT compilation
      NumPy acceleration
      GPU support
    Tech stack
      Python decorator
      LLVM compiler
      CUDA backend
    Use cases
      Numeric loops
      Data science code
      Parallel compute
    Audience
      Scientists
      Data analysts
      Engineers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add a single @jit decorator to a Python function that loops over NumPy arrays to make it run much faster

USE CASE 2

Run number-crunching Python code on a CUDA GPU without rewriting it in a lower-level language

USE CASE 3

Automatically parallelize Python loops across multiple CPU cores without writing threading code

Tech stack

PythonLLVMNumPyCUDA

Getting it running

Difficulty · moderate Time to first run · 30min

GPU support requires a CUDA-compatible NVIDIA graphics card and the CUDA toolkit installed.

Free to use under an open source license sponsored by Anaconda.

In plain English

Numba is a tool that makes Python code run much faster, particularly code that does a lot of number crunching. Python is known for being easy to write but slow to execute compared to lower-level languages. Numba bridges that gap by compiling your Python functions into machine code at the moment they are first called, using a technology called LLVM that many professional compilers rely on. The main audience is scientists, engineers, and data analysts who write Python code that works with large arrays of numbers. Numba is built to work closely with NumPy, a library for numerical computing that is widely used in that community. You add a single decorator (a short annotation above a function) and Numba takes care of the compilation automatically, with no need to rewrite your logic in a faster language. Beyond speeding up regular Python loops and math operations, Numba can also run code on a GPU (the graphics processor, which excels at doing many calculations in parallel). It also supports automatic parallelization, meaning it can split certain loops across multiple processor cores without you having to write any threading code yourself. Numba is sponsored by Anaconda, a company that builds tools for data science, and is free to use under an open source license. The README is brief and points to the project website and documentation for installation steps and full details. Demo notebooks are available via the mybinder.org service if you want to try it without installing anything locally.

Copy-paste prompts

Prompt 1
Show me how to use the @jit decorator in Numba to speed up a Python function that iterates over a large NumPy array
Prompt 2
How do I write a Numba-compiled function that runs on a CUDA GPU?
Prompt 3
Walk me through using Numba's parallel=True option to distribute a NumPy loop across all CPU cores
Prompt 4
What kinds of Python code can Numba speed up and what are the main limitations to watch out for?
Prompt 5
How do I measure the actual speedup from Numba compilation and verify it is working correctly?
Open on GitHub → Explain another repo

← numba on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.