[Python-ideas] Inline Functions - idea

Skip Montanaro skip at pobox.com
Wed Feb 5 15:49:34 CET 2014


I'm not convinced this particular example needs an inline function.
Just write saveLine() as a normal function and pass in your locals:

def f():
    a = 1
    b = 7
    compute(**locals())

def g():
    a = 3
    b = 0.9
    compute(**locals())

def compute(**args):
    print args["a"] + args["b"]

f()
g()

That's not to say inline functions might not be handy. It's possible
that you can implement them without modifying the language either. A
peephole optimizer could inline small functions which are used a lot.

Skip


More information about the Python-ideas mailing list