Skip to main content

Menu

LEVEL 0
0/5 XP
HomeAboutTopicsPricingMy VaultStatsPractice TestsCertifications

Categories

🎓 Certifications
🤖 Artificial Intelligence
☁️ Cloud and Infrastructure
💾 Data and Databases
💼 Professional Skills
🎯 Programming and Development
🔒 Security and Networking
📚 Specialized Topics
CheatGrid
HomeAboutTopicsPricingMy VaultStatsPractice TestsCertifications
LVLEVEL 0
0/5 XP
GitHub
© 2026 CheatGrid™. All rights reserved.
Privacy PolicyTerms of UseAboutContact

Numba Cheat Sheet

Numba Cheat Sheet

Back to Data Science
Updated 2026-05-28
Next Topic: NumPy Scientific Computing Cheat Sheet

Numba is an open-source just-in-time (JIT) compiler for Python that translates Python functions and NumPy array operations into optimized machine code using the LLVM compiler. Sponsored by Anaconda, Numba specializes in numerical and scientific computing where performance is critical, offering substantial speedups (often 10–100×) with minimal code changes. The key insight is that Numba targets array-oriented numerical code particularly well — loops over NumPy arrays, mathematical computations, and parallel operations that would be slow in pure Python execute at speeds approaching C or Fortran. As of Numba 0.65.x (2026), @jit defaults to nopython mode, the built-in CUDA target is deprecated in favor of the numba-cuda package, and experimental free-threading (Python 3.14t) support has been added.

What This Cheat Sheet Covers

This topic spans 20 focused tables and 191 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.

Table 1: Core JIT DecoratorsTable 2: Compilation Modes and OptionsTable 3: Type Inference and SignaturesTable 4: Parallel Execution PatternsTable 5: NumPy Array OperationsTable 6: CUDA GPU ProgrammingTable 7: Typed ContainersTable 8: Performance OptimizationTable 9: Advanced Decorators and ExtensionsTable 10: Troubleshooting and DebuggingTable 11: Common Limitations and WorkaroundsTable 12: Compilation StrategiesTable 13: Type Specifications for jitclassTable 14: Alternative GPU BackendsTable 15: Random Number GenerationTable 16: Stencil OperationsTable 17: Memory Management and Data TransferTable 18: Interoperability and IntegrationTable 19: Best Practices and Common PatternsTable 20: Version Compatibility

Table 1: Core JIT Decorators

The decorator you choose is the most consequential decision when using Numba — it determines compilation mode, target device, and output type. Start with @njit for CPU numerical code, and reach for @vectorize or @cuda.jit only when you specifically need ufuncs or GPU execution.

DecoratorExampleDescription
@njit
@njit
def f(x):
return x + 1
• Alias for @jit(nopython=True) — the recommended default
• forces nopython mode and raises error immediately if compilation fails instead of falling back.
@jit
@jit
def f(x):
return x * 2
• Compiles using lazy JIT compilation (on first call)
• since Numba 0.59, defaults to nopython mode (no longer falls back to object mode automatically).
@jit(nopython=True)
@jit(nopython=True)
def compute(a, b):
return a @ b
• Equivalent to @njit
• explicit form still widely seen in older code
• Redundant since 0.59 but still valid and readable
@jit(signature)
@jit('float64(float64, float64)')
def add(x, y):
return x + y
• Eager compilation with explicit type signature
• compiles immediately at definition time rather than on first call.
@vectorize
@vectorize(['float64(float64)'])
def square(x):
return x ** 2
• Creates a NumPy universal function (ufunc) from a scalar function
• automatically broadcasts over arrays element-wise; supports cpu, parallel, and cuda targets.

More in Data Science

  • Network Analysis with NetworkX Cheat Sheet
  • NumPy Scientific Computing Cheat Sheet
  • AB Testing and Online Experimentation Cheat Sheet
  • Design of Experiments (DOE) Cheat Sheet
  • OpenRefine Cheat Sheet
  • SciPy Cheat Sheet
View all 47 topics in Data Science