I have this Python 3 pseudo-code:
def f1():
a, b, c, d, e, f = some_other_fn()
if (condition):
f2(a, b, c, d, e, f)
def f2(a, b, c, d, e, f):
complex_set_of_operations_with(a, b, c, d, e, f)
for i in range(1000):
f(1)
Now, I am kind of annoyed at the long signature and repetition in f2() and would like to encapsulate that into f1():
def f1():
def f2():
complex_set_of_operations_with(a, b, c, d, e, f)
a, b, c, d, e, f = some_other_fn()
if (condition):
f2()
for i in range(1000):
f(1)
Now, my question is: if I run f1() a thousand times, does the interpreter have to parse f2() a thousand times or is it smart enough to create a reusable reference?
def f2(*args): complex_set_of_operations_with(*args)f2recursively, or in more than one place inf1? If not, you could just dropf2entirely and inline it's code intof1.a,b,c,d,e, andfindividually different places withinf2()and I find it more readable to have them declared explicitly.f1that is also why I want to encapsulate it. I could inline it, but I like to keep the operational code separate from the conditions that trigger it. It's mostly a style and readability question—and admittedly, with some academic curiosity added.