lisa.utils.LazyMapping#
- class lisa.utils.LazyMapping(*args, **kwargs)[source]#
Bases:
MappingLazy Mapping dict-like class for elements evaluated on the fly.
It takes the same set of arguments as a dict with keys as the mapping keys and values as closures that take a key and return the value. The class does no automatic memoization but memoization can easily be achieved using
functools.lru_cache(), as shown in the example below.Example:
LazyMapping({ x: lru_cache()(lambda k: k + 42) for x in [1, 2, 3, 4] })
Attributes
__reversed__inheritedSee
collections.abc.Mapping.__reversed__Methods
__class_getitem__()inheritedSee
collections.abc.Iterable.__class_getitem__()__contains__()inheritedSee
collections.abc.Mapping.__contains__()get()inheritedSee
collections.abc.Mapping.get()items()inheritedSee
collections.abc.Mapping.items()keys()inheritedSee
collections.abc.Mapping.keys()values()inheritedSee
collections.abc.Mapping.values()
Attributes#
- LazyMapping.__reversed__ = None#
Methods#
- classmethod LazyMapping.__class_getitem__()#
Inherited method, see
collections.abc.Iterable.__class_getitem__()
- LazyMapping.__contains__(key)#
Inherited method, see
collections.abc.Mapping.__contains__()
- LazyMapping.get(k[, d]) D[k] if k in D, else d. d defaults to None.#
Inherited method, see
collections.abc.Mapping.get()
- LazyMapping.items() a set-like object providing a view on D's items#
Inherited method, see
collections.abc.Mapping.items()
- LazyMapping.keys() a set-like object providing a view on D's keys#
Inherited method, see
collections.abc.Mapping.keys()
- LazyMapping.values() an object providing a view on D's values#
Inherited method, see
collections.abc.Mapping.values()