.. _pysupported: ========================= Supported Python features ========================= Apart from the :ref:`pysupported-language` part below, which applies to both :term:`object mode` and :term:`nopython mode`, this page only lists the features supported in :term:`nopython mode`. .. _pysupported-language: Language ======== Constructs ---------- Numba strives to support as much of the Python language as possible, but some language features are not available inside Numba-compiled functions: * Function definition * Class definition * Exception handling (``try .. except``, ``try .. finally``) * Context management (the ``with`` statement) The ``raise`` statement is only supported in the simplest form of raising a type without explicitly creating an instance, i.e. ``raise TypeError`` is possible but not ``raise TypeError("some message")``. Similarly, the ``assert`` statement is only supported without an explicit error message. Function calls -------------- Numba supports function calls using positional and named arguments. ``*args`` and ``**kwargs`` are not supported. Built-in types ============== int, bool --------- Arithmetic operations as well as truth values are supported. The following attributes and methods are supported: * ``.conjugate()`` * ``.real`` * ``.imag`` float, complex -------------- Arithmetic operations as well as truth values are supported. The following attributes and methods are supported: * ``.conjugate()`` * ``.real`` * ``.imag`` tuple ----- Tuple construction and unpacking is supported. None ---- The :const:`None` value is supported for identity testing (when using an :class:`~numba.optional` type). Built-in functions ================== The following built-in functions are supported: * :func:`abs` * :class:`bool` * :class:`complex` * :func:`enumerate` * :class:`float` * :class:`int`: only the one-argument form * :func:`len` * :func:`min`: only the multiple-argument form * :func:`max`: only the multiple-argument form * :func:`print`: only numbers and strings; no ``file`` or ``sep`` argument * :class:`range` * :func:`round`: only the two-argument form * :func:`zip` Standard library modules ======================== ``cmath`` --------- The following functions from the :mod:`cmath` module are supported: * :func:`cmath.acos` * :func:`cmath.acosh` * :func:`cmath.asin` * :func:`cmath.asinh` * :func:`cmath.atan` * :func:`cmath.atanh` * :func:`cmath.cos` * :func:`cmath.cosh` * :func:`cmath.exp` * :func:`cmath.isfinite` * :func:`cmath.isinf` * :func:`cmath.isnan` * :func:`cmath.log` * :func:`cmath.log10` * :func:`cmath.phase` * :func:`cmath.polar` * :func:`cmath.rect` * :func:`cmath.sin` * :func:`cmath.sinh` * :func:`cmath.sqrt` * :func:`cmath.tan` * :func:`cmath.tanh` ``ctypes`` ---------- Numba is able to call ctypes-declared functions with the following argument and return types: * :class:`ctypes.c_int8` * :class:`ctypes.c_int16` * :class:`ctypes.c_int32` * :class:`ctypes.c_int64` * :class:`ctypes.c_uint8` * :class:`ctypes.c_uint16` * :class:`ctypes.c_uint32` * :class:`ctypes.c_uint64` * :class:`ctypes.c_float` * :class:`ctypes.c_double` * :class:`ctypes.c_void_p` ``math`` -------- The following functions from the :mod:`math` module are supported: * :func:`math.acos` * :func:`math.acosh` * :func:`math.asin` * :func:`math.asinh` * :func:`math.atan` * :func:`math.atan2` * :func:`math.atanh` * :func:`math.ceil` * :func:`math.copysign` * :func:`math.cos` * :func:`math.cosh` * :func:`math.degrees` * :func:`math.exp` * :func:`math.expm1` * :func:`math.fabs` * :func:`math.floor` * :func:`math.hypot` * :func:`math.isfinite` * :func:`math.isinf` * :func:`math.isnan` * :func:`math.log` * :func:`math.log10` * :func:`math.log1p` * :func:`math.pow` * :func:`math.radians` * :func:`math.sin` * :func:`math.sinh` * :func:`math.sqrt` * :func:`math.tan` * :func:`math.tanh` * :func:`math.trunc` ``operator`` ------------ The following functions from the :mod:`operator` module are supported: * :func:`operator.add` * :func:`operator.and_` * :func:`operator.div` (Python 2 only) * :func:`operator.eq` * :func:`operator.floordiv` * :func:`operator.ge` * :func:`operator.gt` * :func:`operator.iadd` * :func:`operator.iand` * :func:`operator.idiv` (Python 2 only) * :func:`operator.ifloordiv` * :func:`operator.ilshift` * :func:`operator.imod` * :func:`operator.imul` * :func:`operator.invert` * :func:`operator.ior` * :func:`operator.ipow` * :func:`operator.irshift` * :func:`operator.isub` * :func:`operator.itruediv` * :func:`operator.ixor` * :func:`operator.le` * :func:`operator.lshift` * :func:`operator.lt` * :func:`operator.mod` * :func:`operator.mul` * :func:`operator.ne` * :func:`operator.neg` * :func:`operator.not_` * :func:`operator.or_` * :func:`operator.pos` * :func:`operator.pow` * :func:`operator.rshift` * :func:`operator.sub` * :func:`operator.truediv` * :func:`operator.xor` Third-party modules =================== .. I put this here as there's only one module (apart from Numpy), otherwise it should be a separate page. ``cffi`` -------- Similarly to ctypes, Numba is able to call into `cffi`_-declared external functions, using the following C types: * :c:type:`char` * :c:type:`short` * :c:type:`int` * :c:type:`long` * :c:type:`long long` * :c:type:`unsigned char` * :c:type:`unsigned short` * :c:type:`unsigned int` * :c:type:`unsigned long` * :c:type:`unsigned long long` * :c:type:`int8_t` * :c:type:`uint8_t` * :c:type:`int16_t` * :c:type:`uint16_t` * :c:type:`int32_t` * :c:type:`uint32_t` * :c:type:`int64_t` * :c:type:`uint64_t` * :c:type:`float` * :c:type:`double` * :c:type:`char *` * :c:type:`void *` * :c:type:`uint8_t *` * :c:type:`ssize_t` * :c:type:`size_t` * :c:type:`void` .. _cffi: https://cffi.readthedocs.org/