deferred_mappings.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:MDT 作者: cbclab 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号