I have a method that parses strings, and a dictionary argument provides replacements for some substrings, so it doesn't have to be mutable. This function is called often on redundant elements, so caching would improve efficiency. Since dict is mutable and thus not hashable, @functools.lru_cache can't decorate my function. How can I overcome this? Bonus point if it needs only standard library classes and methods (ideally some kind of frozendict in the standard library). PS: namedtuple only in last resort, since it would need a big syntax shift. Continue reading...