cost of closure
tags: learning programming
content
comparing two functions:
- with closure
def outer_func():
def inner_func():
pass
return inner_func()- without closure
def func1():
return _func1()
def _func1():
passwith closure- all logic is in one code block, self-contained
- it’s creating a new function object
inner_funcevery timeouter_funcis called, there’s a runtime cost