lisa.utils.LazyMapping#
- class lisa.utils.LazyMapping(*args, **kwargs)[source]#
Bases:
Mapping
Lazy 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__()#
Inherited method, see
collections.abc.Mapping.__contains__()
- LazyMapping.get()#
Inherited method, see
collections.abc.Mapping.get()
- LazyMapping.items()#
Inherited method, see
collections.abc.Mapping.items()
- LazyMapping.keys()#
Inherited method, see
collections.abc.Mapping.keys()
- LazyMapping.values()#
Inherited method, see
collections.abc.Mapping.values()