Skip to content

decorators module

Class and function decorators.


cacheable function

cacheable(
    *args,
    use_cache=False,
    whitelist=False,
    max_size=None,
    ignore_args=None,
    **options
)

Cacheable function decorator.

See notes on cacheable_property.

Note

To decorate an instance method, use cacheable_method().


cacheable_method function

cacheable_method(
    *args,
    use_cache=False,
    whitelist=False,
    max_size=None,
    ignore_args=None,
    **options
)

Cacheable method decorator.

See notes on cacheable_property.


cached function

cached(
    *args,
    **options
)

cacheable() with use_cache set to True.

Note

To decorate an instance method, use cached_method().


cached_method function

cached_method(
    *args,
    **options
)

cacheable_method() with use_cache set to True.


custom_function function

custom_function(
    *args,
    **options
)

Custom function decorator.


custom_method function

custom_method(
    *args,
    **options
)

Custom method decorator.


cacheable_functionT class

cacheable_functionT(
    *args,
    **kwargs
)

Base class for protocol classes.

Protocol classes are defined as::

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example::

__ class C__

def meth(self) -> int:
    return 0

def func(x: Proto) -> int: return x.meth()

func(C()) # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as::

class GenProto(Protocol[T]):
    def meth(self) -> T:
        ...

Superclasses


get_ca_setup class variable


is_cacheable class variable


cacheable_methodT class

cacheable_methodT(
    *args,
    **kwargs
)

Base class for protocol classes.

Protocol classes are defined as::

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example::

__ class C__

def meth(self) -> int:
    return 0

def func(x: Proto) -> int: return x.meth()

func(C()) # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as::

class GenProto(Protocol[T]):
    def meth(self) -> T:
        ...

Superclasses


get_ca_setup class variable


cacheable_property class

cacheable_property(
    func,
    use_cache=False,
    whitelist=False,
    **options
)

Extends custom_property for cacheable properties.

Note

Assumes that the instance (provided as self) won't change. If calculation depends upon object attributes that can be changed, it won't notice the change.

Superclasses

Inherited members

Subclasses


get_ca_setup method

cacheable_property.get_ca_setup(
    instance=None
)

Get setup of type CARunSetup if instance is known, or CAUnboundSetup otherwise.

See vectorbtpro.registries.ca_registry for details on the caching procedure.


init_use_cache property

Initial value for use_cache.


init_whitelist property

Initial value for whitelist.


cached_property class

cached_property(
    func,
    **options
)

cacheable_property with use_cache set to True.

Superclasses

Inherited members


class_or_instanceproperty class

class_or_instanceproperty(
    func
)

Property that binds self to a class if the function is called as class method, otherwise to an instance.


func property

Wrapped function.


classproperty class

classproperty(
    func
)

Property that can be called on a class.


func property

Wrapped function.


custom_functionT class

custom_functionT(
    *args,
    **kwargs
)

Base class for protocol classes.

Protocol classes are defined as::

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example::

__ class C__

def meth(self) -> int:
    return 0

def func(x: Proto) -> int: return x.meth()

func(C()) # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as::

class GenProto(Protocol[T]):
    def meth(self) -> T:
        ...

Superclasses

  • typing.Generic
  • typing.Protocol

Subclasses


func class variable


is_method class variable


name class variable


options class variable


custom_methodT class

custom_methodT(
    *args,
    **kwargs
)

Base class for protocol classes.

Protocol classes are defined as::

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example::

__ class C__

def meth(self) -> int:
    return 0

def func(x: Proto) -> int: return x.meth()

func(C()) # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as::

class GenProto(Protocol[T]):
    def meth(self) -> T:
        ...

Superclasses

Subclasses


custom_property class

custom_property(
    func,
    **options
)

Custom extensible property that stores function and options as attributes.

Note

custom_property instances belong to classes, not class instances. Thus changing the property will do the same for each instance of the class where the property has been defined initially.

Superclasses

  • builtins.property

Subclasses


func property

Wrapped function.


name property

Wrapped function name.


options property

Options.