{"id":545,"library":"numba","title":"Numba: High Performance Python Compiler","description":"Numba is an open-source, NumPy-aware optimizing Just-In-Time (JIT) compiler for Python. It translates a subset of Python and NumPy code into fast machine code using the LLVM compiler library, enabling numerical algorithms to approach the speeds of C or Fortran without requiring a separate compilation step. Numba is currently at version 0.64.0 and maintains a regular release cadence, often coinciding with Python and NumPy releases.","status":"active","version":"0.64.0","language":"python","source_language":"en","source_url":"https://github.com/numba/numba","tags":["compiler","jit","performance","numpy","scientific computing","gpu","cuda"],"install":[{"cmd":"pip install numba","lang":"bash","label":"PyPI"},{"cmd":"conda install numba","lang":"bash","label":"Anaconda/Miniconda"}],"dependencies":[{"reason":"Numba is designed to work seamlessly with NumPy arrays and functions, generating specialized code for different array data types and layouts to optimize performance.","package":"numpy"},{"reason":"Numba uses llvmlite to bind to the LLVM compiler library, which generates the machine code. Numba bundles the required LLVM components within the llvmlite wheel.","package":"llvmlite"},{"reason":"Enables support for compiling `numpy.linalg` functions and provides additional functionality.","package":"scipy","optional":true},{"reason":"Required for NVIDIA GPU acceleration with Numba when installing via conda. For pip, the CUDA SDK from NVIDIA is needed.","package":"cudatoolkit","optional":true}],"imports":[{"note":"`jit` is typically imported directly from the `numba` package as a decorator, not as a submodule.","wrong":"import numba.jit","symbol":"jit","correct":"from numba import jit"},{"note":"`njit` is a shorthand for `@jit(nopython=True)`, ensuring Numba generates code that doesn't fall back to the Python interpreter, which is often desired for performance.","symbol":"njit","correct":"from numba import njit"},{"symbol":"guvectorize","correct":"from numba import guvectorize"}],"quickstart":{"code":"import numpy as np\nfrom numba import njit\n\n@njit\ndef sum_array(arr):\n    total = 0.0\n    for x in arr:\n        total += x\n    return total\n\n# Example usage\ndata = np.arange(1000000, dtype=np.float64)\nresult = sum_array(data)\nprint(f\"Sum of array: {result}\")","lang":"python","description":"This quickstart demonstrates the core usage of Numba's `@njit` decorator to compile a Python function for numerical computation. The function `sum_array` iterates over a NumPy array, and when decorated with `@njit`, Numba compiles it to highly optimized machine code at runtime, significantly speeding up its execution compared to pure Python."},"warnings":[{"fix":"Either recompile the function after modifying the global variable or, preferably, refactor your code to pass the variable as an argument to the jitted function.","message":"Numba treats global variables as compile-time constants. Modifying a global variable after a `@jit` decorated function has been compiled will not affect the compiled function's behavior unless the function is explicitly recompiled using `.recompile()` or the global is passed as an argument.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure that all operations and data types within a `@njit` (nopython mode) function are supported by Numba and that types are consistent. Explicitly casting types (e.g., using `np.int64(0)` instead of `0`) can sometimes help with type propagation.","message":"Type inference failures are a common reason for Numba compilation errors, especially in `nopython` mode. Numba needs to determine concrete types for all variables; if it cannot, compilation will fail.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Configure Spyder to exclude `numba` from its User Module Reloader (UMR). Go to `Preferences -> Console -> Advanced Settings`, click 'Set UMR excluded modules', and add `numba`. Restart the IPython console after applying the setting.","message":"Running Numba-compiled scripts twice in IDEs like Spyder can lead to `TypeError: No matching definition for argument type(s)` due to module reloading issues.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Avoid using the `target` kwarg. Numba's decorators like `jit` and `njit` infer the target (CPU by default) or specific GPU decorators like `cuda.jit` should be used for explicit targets.","message":"The `target` kwarg for the `numba.jit` decorator family has been deprecated.","severity":"deprecated","affected_versions":"Numba 0.51.0 and later"},{"fix":"Numba aims to replace this with a better implementation. Users relying on reflection for these types might need to adapt their code if they observe unexpected behavior or warnings in future versions. Pinning Numba dependency is recommended if relying on this behavior.","message":"Reflection for Python `List` and `Set` types within Numba-compiled code is deprecated. This feature ensured changes to mutable Python containers were visible after the function returned.","severity":"deprecated","affected_versions":"Numba 0.50.0 and later"},{"fix":"Update to Numba 0.64.0 or later to ensure compatibility with NumPy 2.x. Review Numba's documentation and NumPy 2.0 migration guides for potential code adjustments, especially concerning type interactions.","message":"Numba 0.64.0 supports NumPy 2.3 and 2.4. NumPy 2.0 introduces binary incompatible changes and a new type system. Numba has evolved to accommodate this, but users should be prepared to test and verify their codebases, as NumPy 2.0 may also impact non-JIT compiled code output.","severity":"breaking","affected_versions":"Numba 0.60.0 (initial support) to 0.64.0 (full support for 2.3/2.4) onwards"},{"fix":"Code relying on the experimental RVSDG frontend will no longer function. Users should remove any explicit enabling of this frontend from their Numba configurations.","message":"The experimental RVSDG (Region-based Value Stream Dependence Graph) frontend was removed in Numba 0.61.0.","severity":"breaking","affected_versions":"Numba 0.61.0 and later"},{"fix":"Ensure that the necessary build tools are installed in your environment. For Debian-based systems, use `apt-get install build-essential cmake`. For Alpine Linux, use `apk add build-base cmake`. For other operating systems, consult their documentation for installing development tools and CMake.","message":"Building Numba and its dependencies (like llvmlite) requires system-level development tools such as a C compiler (e.g., GCC) and CMake. These tools are often not included in minimal base images or environments (e.g., Alpine Linux) by default.","severity":"breaking","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T14:52:19.543Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Ensure Numba is installed in your active environment using `pip install numba` or `conda install numba`. Verify the Python executable by checking `which python` and `which pip` (or `where python` and `where pip` on Windows) to ensure they belong to the same environment. If using Jupyter/IPython, restart the kernel after installation.","cause":"Numba is not installed in the currently active Python environment, or there is a mismatch between the Python interpreter used for installation and the one used for execution.","error":"ModuleNotFoundError: No module named 'numba'"},{"fix":"Inspect the types of variables within the jitted function using `my_jitted_func.inspect_types()`. Ensure all operations and data types are supported by Numba (consult Numba documentation for supported features). Often, this means avoiding dynamic Python features like heterogeneous lists or unsupported object methods. Consider explicitly casting types where Numba's inference struggles, or refactoring code to use NumPy arrays and operations. If this occurs in an IDE like Spyder, try adding `numba` to the UMR excluded modules in preferences and restarting the console.","cause":"Numba, especially in `nopython` mode, failed to infer the types of arguments or found an operation between types that it does not support, preventing compilation to native code.","error":"TypeError: No matching definition for argument type(s)"},{"fix":"To achieve performance benefits, compilation must succeed in `nopython` mode. Explicitly use `@numba.njit` (which is shorthand for `@numba.jit(nopython=True)`) to force `nopython` mode. This will raise an error instead of silently falling back, giving specific details about what Numba cannot compile. Refactor the problematic parts of the code to use Numba-supported types and operations. Use `my_jitted_func.inspect_types()` to see which variables are typed as `pyobject`, indicating areas that prevented `nopython` compilation.","cause":"Numba attempted to compile the function in `nopython` mode but encountered Python features or types it could not translate to machine code. It then silently fell back to 'object mode', which offers little to no performance improvement over regular Python.","error":"NumbaWarning: Function \"...\" was compiled in object mode without forceobj=True. Fall-back from the nopython compilation path to the object mode compilation path has been detected, this is deprecated behaviour."},{"fix":"Identify the line of code and the specific operation/function call mentioned in the full traceback. Examine the types of the arguments being passed to that operation. Ensure that the types are primitive (e.g., `int`, `float`), NumPy arrays, or other Numba-supported types, and that the operation is valid for those types within Numba. Avoid passing Python objects, lists, or dictionaries unless specifically supported by Numba for that operation. Consider explicitly defining function signatures or local variable types if inference is failing.","cause":"This specific message indicates that Numba's type inference could not resolve an operation (e.g., a function call or arithmetic operation) because one or more arguments had a type that the operation does not support within Numba's compilation context, particularly in `nopython` mode.","error":"This error is usually caused by passing an argument of a type that is unsupported by the named function."}],"ecosystem":"pypi","meta_description":null,"install_score":50,"install_tag":"draft","quickstart_score":33,"quickstart_tag":"draft","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"draft","tag_description":"notable install failures or slow imports","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.96,"mem_mb":22.6,"disk_size":"274M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.01,"mem_mb":25.4,"disk_size":"288M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.05,"mem_mb":24.8,"disk_size":"275M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.03,"mem_mb":24,"disk_size":"274M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":1,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.92,"mem_mb":21.3,"disk_size":"251M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"draft","tag_description":"notable failures across runtimes","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}