I created an initial implementation of the decorator in
def memoize(func):
"""Simple decorator to memoize the return value of a function with no
argument.
See https://stackoverflow.com/questions/5630409
for the use of nonlocal in the body of the wrapper function.
"""
cache = None
@functools.wraps(func)
def wrapper():
nonlocal cache
if cache is None:
cache = func()
return cache
return wrapper
I created an initial implementation of the decorator in