you could also use @functools.lru_cache(maxsize=1024) instead of maintaining own caching code