Skip to content

jitting module

Utilities for jitting.


get_func_suffix function

get_func_suffix(
    py_func
)

Get the suffix of the function.


get_id_of_jitter_type function

get_id_of_jitter_type(
    jitter_type
)

Get id of a jitter type using jitters in jitting.


jitted function

jitted(
    *args,
    tags=None,
    **jitted_kwargs
)

Decorate a jitable function.

Resolves jitter using resolve_jitter.

The wrapping mechanism can be disabled by using the global setting disable_wrapping (=> returns the wrapped function).

Usage

>>> from vectorbtpro import *

>>> @vbt.jitted
... def my_func_nb():
...     total = 0
...     for i in range(1000000):
...         total += 1
...     return total

>>> %timeit my_func_nb()
68.1 ns ± 0.32 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)

Jitter is automatically detected using the suffix of the wrapped function.


resolve_jitted_kwargs function

resolve_jitted_kwargs(
    option=None,
    **kwargs
)

Resolve keyword arguments for jitted.

Resolves option using resolve_jitted_option.

Note

Keys in option have more priority than in kwargs.


resolve_jitted_option function

resolve_jitted_option(
    option=None
)

Return keyword arguments for jitted.

option can be:

  • True: Decorate using default settings
  • False: Do not decorate (returns None)
  • string: Use option as the name of the jitter
  • dict: Use option as keyword arguments for jitting

For defaults, see option in jitting.


resolve_jitter function

resolve_jitter(
    jitter=None,
    py_func=None,
    **jitter_kwargs
)

Resolve jitter.

Note

If jitter is already an instance of Jitter and there are other keyword arguments, discards them.


resolve_jitter_type function

resolve_jitter_type(
    jitter=None,
    py_func=None
)

Resolve jitter.

  • If jitter is None and py_func is not None, uses get_func_suffix
  • If jitter is a string, looks in jitters in jitting
  • If jitter is a subclass of Jitter, returns it
  • If jitter is an instance of Jitter, returns its class
  • Otherwise, throws an error

specialize_jitted_option function

specialize_jitted_option(
    option=None,
    **kwargs
)

Resolve option and merge it with kwargs if it's not None so the dict can be passed as an option to other functions.


Jitter class

Jitter(
    **config
)

Abstract class for decorating jitable functions.

Represents a single configuration for jitting.

When overriding Jitter.decorate, make sure to check whether wrapping is disabled globally using Jitter.wrapping_disabled.

Superclasses

Inherited members

Subclasses


decorate method

Jitter.decorate(
    py_func,
    tags=None
)

Decorate a jitable function.


wrapping_disabled class property

Whether wrapping is disabled globally.


NumPyJitter class

NumPyJitter(
    **config
)

Class for decorating functions that use NumPy.

Returns the function without decorating.

Superclasses

Inherited members


NumbaJitter class

NumbaJitter(
    fix_cannot_parallel=True,
    nopython=True,
    nogil=True,
    parallel=False,
    cache=False,
    boundscheck=False,
    **options
)

Class for decorating functions using Numba.

Note

If fix_cannot_parallel is True, parallel=True will be ignored if there is no can_parallel tag.

Superclasses

Inherited members


boundscheck class property

Whether to enable bounds checking for array indices.


cache class property

Whether to write the result of function compilation into a file-based cache.


fix_cannot_parallel class property

Whether to set parallel to False if there is no 'can_parallel' tag.


nogil class property

Whether to release the GIL.


nopython class property

Whether to run in nopython mode.


options class property

Options passed to the Numba decorator.


parallel class property

Whether to enable automatic parallelization.