Skip to content
New: Star-import, signal unraveling, Python 3.12 support, and more

#
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(
        **kwargs
    )

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

- Cacheable
- Chainable
- Comparable
- Configured
- HasSettings
- Pickleable
- Prettified

Inherited members

- Cacheable.get_ca_setup()
- Chainable.pipe()
- Configured.config
- Configured.copy()
- Configured.equals()
- Configured.get_writeable_attrs()
- Configured.prettify()
- Configured.rec_state
- Configured.replace()
- Configured.resolve_merge_kwargs()
- Configured.update_config()
- HasSettings.get_path_setting()
- HasSettings.get_path_settings()
- HasSettings.get_setting()
- HasSettings.get_settings()
- HasSettings.has_path_setting()
- HasSettings.has_path_settings()
- HasSettings.has_setting()
- HasSettings.has_settings()
- HasSettings.reset_settings()
- HasSettings.resolve_setting()
- HasSettings.resolve_settings_paths()
- HasSettings.set_settings()
- Pickleable.decode_config()
- Pickleable.decode_config_node()
- Pickleable.dumps()
- Pickleable.encode_config()
- Pickleable.encode_config_node()
- Pickleable.file_exists()
- Pickleable.getsize()
- Pickleable.load()
- Pickleable.loads()
- Pickleable.modify_state()
- Pickleable.resolve_file_path()
- Pickleable.save()

Subclasses

- NumPyJitter
- NumbaJitter

### decorate method

    Jitter.decorate(
        py_func,
        tags=None
    )

Decorate a jitable function.

### wrapping_disabled property

Whether wrapping is disabled globally.

## NumPyJitter class

    NumPyJitter(
        **kwargs
    )

Class for decorating functions that use NumPy.

Returns the function without decorating.

Superclasses

- Cacheable
- Chainable
- Comparable
- Configured
- HasSettings
- Jitter
- Pickleable
- Prettified

Inherited members

- Cacheable.get_ca_setup()
- Chainable.pipe()
- Configured.copy()
- Configured.equals()
- Configured.get_writeable_attrs()
- Configured.prettify()
- Configured.replace()
- Configured.resolve_merge_kwargs()
- Configured.update_config()
- HasSettings.get_path_setting()
- HasSettings.get_path_settings()
- HasSettings.get_setting()
- HasSettings.get_settings()
- HasSettings.has_path_setting()
- HasSettings.has_path_settings()
- HasSettings.has_setting()
- HasSettings.has_settings()
- HasSettings.reset_settings()
- HasSettings.resolve_setting()
- HasSettings.resolve_settings_paths()
- HasSettings.set_settings()
- Jitter.config
- Jitter.decorate()
- Jitter.rec_state
- Jitter.wrapping_disabled
- Pickleable.decode_config()
- Pickleable.decode_config_node()
- Pickleable.dumps()
- Pickleable.encode_config()
- Pickleable.encode_config_node()
- Pickleable.file_exists()
- Pickleable.getsize()
- Pickleable.load()
- Pickleable.loads()
- Pickleable.modify_state()
- Pickleable.resolve_file_path()
- Pickleable.save()

## 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

- Cacheable
- Chainable
- Comparable
- Configured
- HasSettings
- Jitter
- Pickleable
- Prettified

Inherited members

- Cacheable.get_ca_setup()
- Chainable.pipe()
- Configured.copy()
- Configured.equals()
- Configured.get_writeable_attrs()
- Configured.prettify()
- Configured.replace()
- Configured.resolve_merge_kwargs()
- Configured.update_config()
- HasSettings.get_path_setting()
- HasSettings.get_path_settings()
- HasSettings.get_setting()
- HasSettings.get_settings()
- HasSettings.has_path_setting()
- HasSettings.has_path_settings()
- HasSettings.has_setting()
- HasSettings.has_settings()
- HasSettings.reset_settings()
- HasSettings.resolve_setting()
- HasSettings.resolve_settings_paths()
- HasSettings.set_settings()
- Jitter.config
- Jitter.decorate()
- Jitter.rec_state
- Jitter.wrapping_disabled
- Pickleable.decode_config()
- Pickleable.decode_config_node()
- Pickleable.dumps()
- Pickleable.encode_config()
- Pickleable.encode_config_node()
- Pickleable.file_exists()
- Pickleable.getsize()
- Pickleable.load()
- Pickleable.loads()
- Pickleable.modify_state()
- Pickleable.resolve_file_path()
- Pickleable.save()

### boundscheck property

Whether to enable bounds checking for array indices.

### cache property

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

### fix_cannot_parallel property

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

### nogil property

Whether to release the GIL.

### nopython property

Whether to run in nopython mode.

### options property

Options passed to the Numba decorator.

### parallel property

Whether to enable automatic parallelization.

#### Cookie consent

We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better.

- Google Analytics
- GitHub

Manage settings