Benchmarks: When Numba Edges Out Cython

For specific array-based numerical computations, Numba can sometimes surpass highly optimized Cython, achieving speedups up to 1300x with a single decorator for simple Python code. Conversely, Cython often provides more consistent low-level optimization for complex algorithms or C/C++ bindings.

The top 3

  1. Numba's Numerical Loop Dominance: Up to 100x Speedups: For computationally intensive numerical loops, especially those involving NumPy arrays, Numba's JIT compilation frequently delivers 30x to 100x or more speedups, often matching or exceeding Cython with minimal code changes like a simple decorator.
  2. Minimal Code, Max Speed: Numba Outperforms Optimized Cython: In specific benchmarks, such as a pairwise distance function, Numba's simple `@njit` decorator achieved a 1300x speedup over plain Python and was even a few percent faster than a highly optimized Cython version.
  3. Scaling Performance: Numba's Edge in Large Operations: As the number of operations and computational complexity increase, Numba's JIT compilation often demonstrates significantly faster runtime and better scalability compared to Cython.

Sources

Open the full topic