Numba is a Python compiler that uses type information to generate optimized machine code from Python functions. It allows Python code to run as fast as natively compiled languages for numeric computation. The goal is to provide rapid iteration and development along with fast code execution. Numba works by compiling Python code to LLVM bitcode then to machine code using type information from NumPy. An example shows a sinc function being JIT compiled. Future work includes supporting more Python features like structures and objects.
2. Motivation
Python is great for rapid development
and high-level thinking-in-code
It is slow for interior loops because lack
of type information leads to a lot of
indirection and extra code.
3. Motivation
NumPy users have a lot of type
information --- but only currently have
one-size 鍖ts all pre-compiled, vectorized
loops.
Many new features envisioned will need
the ability for high-level expressions to
be compiled to machine code.
4. Goal:
rapid iteration and development
+
fast code execution
Numba should be the worlds best
array-oriented compiler.
5. NumPy + Mamba = Numba
Python Function Machine Code
LLVM-PY
LLVM Library
ISPC OpenCL OpenMP CUDA CLANG
Intel AMD Nvidia Apple ARM
6. Example
Numba
@jit(f8(f8))
def sinc(x):
if x==0.0:
return 1.0
else:
return sin(x*pi)/(pi*x)
7. Status and Future
My early bytecode branch further developed by
Jon Riehl (Resilient Science) sponsored by
Continuum Analytics, Inc. --- interprets bytecode
directly
Current trunk works with AST directly and
making rapid progress
- Mark Florrison (minivect)
- Siu Kwan Lam (pymothoa)
9. RoadMap
Numba 0.2 available now
Github trunk has many changes -- 0.3 will support
- structures
- Python code
- objects with inheritance
Check out NumbaPro
for cutting-edge features
10. Software Stack Future?
Plateaus of Code re-use + DSLs
SQL R
TDPL Matlab
Python
OBJC C
FORTRAN C++
LLVM