functools.lru_cache() actually will not work because of the issue mentioned in this thread.
functools.lru_cache()