How numba/numba works
Numba is a NumPy-aware just-in-time compiler that turns supported Python numerical functions into machine code, with additional parallel, GPU, ufunc, and C-callback capabilities. The principal workflow starts at the public JIT API, dispatches compilation, analyzes and types code, then lowers it through a target backend to generated code. The graph also preserves documented parallel/GPU and array support. Some compiler-stage links are dashed because the relevant call sites were not sampled; README statements support the major product capabilities.
Main entry points: compiler.py Compilation pipeline · decorators.py JIT decorators · dispatcher.py Function dispatcher · typeinfer.py Type inference
Components 19
Public API
- JIT decorators
numba/core/decorators.py - Function dispatcher
numba/core/dispatcher.py - C callbacks
numba/core/ccallback.py
Compiler Core
- Compilation pipeline
numba/core/compiler.py - Bytecode analysis
numba/core/bytecode.py - Intermediate representation
numba/core/ir.py - Type inference
numba/core/typeinfer.py - Typing rules
numba/core/typing/collections.py - Type system
numba/core/types/abstract.py
Code Generation
- Native lowering
numba/core/lowering.py - LLVM code generation
numba/core/codegen.py
Numerical Features
- NumPy arrays
numba/np/arrayobj.py - NumPy type support
numba/np/numpy_support.py - Loop parallelization
numba/parfors/parfor.py - Ufunc creation
numba/np/ufunc/ufuncbuilder.py
Accelerators
- CUDA API
numba/cuda/api.py - CUDA compilation
numba/cuda/compiler.py - CUDA device driver
numba/cuda/cudadrv/driver.py
Other components
- Python developer
Connections 18
- Python developer → JIT decorators: decorates function
- JIT decorators → Function dispatcher: creates dispatcher
- Function dispatcher → Compilation pipeline: requests compilation
- Compilation pipeline → Bytecode analysis: analyzes bytecode
- Compilation pipeline → Intermediate representation: builds IR
- Compilation pipeline → Type inference: infers types
- Type inference → Typing rules: resolves operations
- Typing rules → Type system: uses types
numba/core/typing/collections.py - Compilation pipeline → Native lowering: lowers code
- Native lowering → LLVM code generation: emits LLVM
- Python developer → CUDA API: launches kernels
- CUDA API → CUDA compilation: compiles kernels
- CUDA compilation → CUDA device driver: uses device driver
- Python developer → Loop parallelization: parallelizes loops
- Python developer → Ufunc creation: creates ufuncs
- Python developer → C callbacks: creates callbacks
- NumPy arrays → NumPy type support: uses type support
numba/np/arrayobj.py - Compilation pipeline → Loop parallelization: supports parallel loops