Basic usage
Input
def add(a, b): print('calculating') return a + b cached_add = cache_last(add) cached_add(2, 3) cached_add(2, 3)
Output
first call returns 5 and prints 'calculating'; second call returns 5 with no additional print
The first call computes and caches the result. The second identical call returns the cached result without invoking add again.