colour.utilities.LazyCanonicalMapping#
- class colour.utilities.LazyCanonicalMapping(data: Generator | Mapping | None = None, **kwargs: Any)[source]#
Bases:
CanonicalMappingRepresent a lazy delimiter and case-insensitive
dict-like object inheriting fromcolour.utilities.CanonicalMapping.This class extends
CanonicalMappingwith lazy evaluation capabilities. When a value is a callable, it is automatically evaluated upon first access and its return value is cached, replacing the original callable for subsequent retrievals.- Parameters:
Methods
Examples
>>> def callable_a(): ... print(2) ... return 2 >>> methods = LazyCanonicalMapping({"McCamy": 1, "Hernandez": callable_a}) >>> methods["mccamy"] 1 >>> methods["hernandez"] 2 2