Investigate possible slowness with state.get
lru_cache usage is ineffective as the frequent need to clear the cache when state.set is called.
We could write a custom caching with ability to partially clear, e.g. state.set('a.b.c', ...) would need to clear the cache of 'a', 'a.b' and 'a.b.c.d' not just 'a.b.c'. But wouldn't want to clear 'a.b.z'.
But at this point are we at the point of rewriting state to understand which things can and cannot change.
Alternative, is adding a get_constant() that caches a get() call, and change calls throughout the code if it is known that the value never changes.
Edited by Robin Goodall