You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
especially for computation-heavy code: numerical algorithms
Why Numba?
Breaking the speed barrier
Provides JIT for array-oriented programming in CPython
Numerical loops
Low-level C-like code in pure Python
pointers, structs, callbacks
Why Numba?
Work with existing tools
Works with existing CPython extensions
Goal: Integration with scientific software stack
NumPy/SciPy/Blaze
indexing and slicing
array expressions
math
C, C++, Fortran, Cython, CFFI, Julia?
Why Numba?
Minimum effort for Maximum hardware utilization
High level tools for domains experts to exploit modern hardware
multicore CPU
manycore GPU
Easily take advantage of parallelism and accelerators
Software Stack
@jit, @autojit
Instead of JIT-ing all Python code, we target the hotspot
Use decorators to mark functions or classes for just-in-time compilation
Static runtime compilation
@jit(double(double[:, :]))deffunc(array):
...
Dynamic just-in-time specialization
@autojitdeffunc(array):
...
JIT a Class
@jitclassShrubbery(object):
@void(int_, int_)def__init__(self, w, h):
# All instance attributes must be defined in the initializerself.width=wself.height=h# Types can be explicitly specified through castsself.some_attr=double(1.0)
@int_()defarea(self):
returnself.width*self.height@void()defdescribe(self):
print("This shrubbery is ", self.width,
"by", self.height, "cubits.")