Since version 3.2 python we can use a decorator namedfunctools.lru_cache() , this function implement a built-in LRU cache in Python, so lets take a deep look to this functionality
functools.lru_cache()