from functools import lru_cache catalog = {"paper": 5} @lru_cache(maxsize=32) def price(sku): return catalog[sku] print(price("paper")) catalog["paper"] = 6 print(price("paper"))