Hi All,

It is really convenient to use nested functions and lambda
expressions. What I'd like to know is if Python compiles fn_inner()
only once and change the binding of v every time fn_outer() is called
or if Python compile and generate a new function object every time. If
it is the latter, will there be a huge performance hit? Would someone
give some hint about how exactly Python does this internally?

def fn_outer(v):
    a=v*2
    def fn_inner():
        print "V:%d,%d" % (v,a)

    fn_inner()

Thanks,
Geoffrey

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to