The horizon.utils.memoized ModuleΒΆ

exception horizon.utils.memoized.UnhashableKeyWarning[source]

Bases: exceptions.RuntimeWarning

Raised when trying to memoize a function with an unhashable argument.

horizon.utils.memoized.memoized(func)[source]

Decorator that caches function calls.

Caches the decorated function’s return value the first time it is called with the given arguments. If called later with the same arguments, the cached value is returned instead of calling the decorated function again.

The cache uses weak references to the passed arguments, so it doesn’t keep them alive in memory forever.

horizon.utils.memoized.memoized_method(func)

Decorator that caches function calls.

Caches the decorated function’s return value the first time it is called with the given arguments. If called later with the same arguments, the cached value is returned instead of calling the decorated function again.

The cache uses weak references to the passed arguments, so it doesn’t keep them alive in memory forever.

Previous topic

The horizon.utils.escape Module

Next topic

The horizon.utils.filters Module

Project Source

This Page