Technology knowledge has to be shared and made accessible for free. Join the movement.
Functools module supports memoization through lru_cache decorator. This way you dont need to write memoization code.
In the example adding the decorator @lru_cache does the needful. You can also see the cache details with cache_info