def __init__(self, items, cache=True):
"""The items should contain a list of functions that we apply at the moment of request.
On the moment one of the keys of this dict class is requested we apply the function stored in the items dict
for that key and return the result of that function.
The advantage of this class is that it defers an expensive operation until it is needed.
Items set to this dictionary are assumed to be final, that is, we won't run the function on them.
Args:
items (collections.MutableMapping): the items on which we operate, each value should
contain a function with no parameters that we run to return the results.
cache (boolean): if we want to cache computed results
"""
self._items = copy.copy(items)
self._applied_on_key = {}
self._cache = cache
评论列表
文章目录