lisa.utils.lru_memoized#

lisa.utils.lru_memoized(first_param_maxsize=None, other_params_maxsize=1024)[source]#

Decorator to memoize the result of a callable, based on functools.lru_cache()

Parameters:
  • first_param_maxsize (int or None) – Maximum number of cached values for the first parameter, if the decorated function is a method.

  • other_params_maxsize (int or None) – Maximum number of cached combinations of all parameters except the first one.

Note

The first parameter of the callable is cached with a weak reference when the function is a method. This suits well the method use-case, since we don’t want the memoization of methods to prevent garbage collection of the instances they are bound to.