jacinle.utils.cache#

Functions

cached_property(fget)

A decorator that converts a function into a cached property.

cached_result(func)

A decorator that caches the result of a function.

fs_cached_result(filename[, force_update, ...])

A decorator that caches the result of a function into a file.

Functions

cached_property(fget)[source]#

A decorator that converts a function into a cached property. Similar to @property, but the function result is cached. This function has threading lock support.

cached_result(func)[source]#

A decorator that caches the result of a function. Note that this decorator does not support any arguments to the function.

fs_cached_result(filename, force_update=False, verbose=False)[source]#

A decorator that caches the result of a function into a file. Note that this decorator does not take care of any arguments to the function.

Parameters:
  • filename (str) – the filename to store the result.

  • force_update (bool) – if True, the result will be updated even if the file exists.

  • verbose (bool) – if True, the filenames will be printed to the console.

Returns:

a decorator function.

Return type:

Callable[[Callable], Callable]