def wrap(f):
    print('making arr')
arr = []

def inner():
    arr.append(2)
print(arr)
f()
return inner

@wrap
def foo():
    print('foo was called')
foo()
foo()

def bar():
    print('bar was called')
bar = wrap(bar)
bar()
Понимание обработки параметров в декораторе мемоизации Python