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

#
ch_registry module

Global registry for chunkables.

## ch_reg ChunkableRegistry

Default registry of type ChunkableRegistry.

## register_chunkable function

    register_chunkable(
        func=None,
        setup_id=None,
        registry=<vectorbtpro.registries.ch_registry.ChunkableRegistry object>,
        tags=None,
        return_wrapped=False,
        **options
    )

Register a new chunkable function.

If `return_wrapped` is True, wraps with the chunked() decorator. Otherwise, leaves the function as-is (preferred).

Options are merged in the following order:

- `options` in chunking
- `setup_options.{setup_id}` in chunking
- `options`
- `override_options` in chunking
- `override_setup_options.{setup_id}` in chunking

Note

Calling the register_chunkable() decorator before (or below) the register_jitted() decorator with `return_wrapped` set to True won't work. Doing the same after (or above) register_jitted() will work for calling the function from Python but not from Numba. Generally, avoid wrapping right away and use ChunkableRegistry.decorate() to perform decoration.

## ChunkableRegistry class

    ChunkableRegistry()

Class that registers chunkable functions.

### decorate method

    ChunkableRegistry.decorate(
        setup_id_or_func,
        target_func=None,
        **kwargs
    )

Decorate the setup's function using the chunked() decorator.

Finds setup using ChunkableRegistry.get_setup().

Merges setup's options with `options`.

Specify `target_func` to apply the found setup on another function.

### get_setup method

    ChunkableRegistry.get_setup(
        setup_id_or_func
    )

Get setup by its id or function.

`setup_id_or_func` can be an identifier or a function. If it's a function, will build the identifier using its module and name.

### match_setups method

    ChunkableRegistry.match_setups(
        expression=None,
        context=None
    )

Match setups against an expression with each setup being a context.

### register method

    ChunkableRegistry.register(
        func,
        setup_id=None,
        options=None,
        tags=None
    )

Register a new setup.

### resolve_option method

    ChunkableRegistry.resolve_option(
        setup_id_or_func,
        option,
        target_func=None,
        **kwargs
    )

Same as ChunkableRegistry.decorate() but using resolve_chunked().

### setups property

Dict of registered ChunkedSetup instances by ChunkedSetup.setup_id.

## ChunkedSetup class

    ChunkedSetup(
        setup_id,
        func,
        options=None,
        tags=None
    )

Class that represents a chunkable setup.

Note

Hashed solely by `setup_id`.

Method generated by attrs for class ChunkedSetup.

Superclasses

- Hashable

Inherited members

- Hashable.get_hash()
- Hashable.hash
- Hashable.hash_key

### func class variable

Chunkable function.

### options class variable

Options dictionary.

### setup_id class variable

Setup id.

### tags class variable

Set of tags.

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