Re: Speed of Nested Functions & Lambda Expressions

2007-12-07 Thread Terry Jones
> "Duncan" == Duncan Booth <[EMAIL PROTECTED]> writes: Duncan> Terry Jones <[EMAIL PROTECTED]> wrote: >> Duncan Booth wrote: Duncan> You'll kick yourself for not seeing it. Duncan> If you changed fn_inner to: Duncan> def fn_inner(): Duncan> a, v = v, a Duncan> then you also changed 'a' and '

Re: Speed of Nested Functions & Lambda Expressions

2007-12-07 Thread Duncan Booth
Terry Jones <[EMAIL PROTECTED]> wrote: > Duncan Booth wrote: > >> You can use Python's bytecode disassembler to see what actually gets >> executed here: >> >> >>> def fn_outer(v): >> a=v*2 >> def fn_inner(): >> print "V:%d,%d" % (v,a) >> >> fn_inner() >> >> >>> import

Re: Speed of Nested Functions & Lambda Expressions

2007-12-06 Thread Terry Jones
[Referring to the thread at http://mail.python.org/pipermail/python-list/2007-October/463348.html with apologies for top posting (I don't have the original mail)] Duncan Booth wrote: > You can use Python's bytecode disassembler to see what actually gets > executed here: > > >>> def fn_outer(v

Re: Speed of Nested Functions & Lambda Expressions

2007-10-24 Thread beginner
On Oct 24, 2:52 am, Duncan Booth <[EMAIL PROTECTED]> wrote: > beginner <[EMAIL PROTECTED]> wrote: > > 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

Re: Speed of Nested Functions & Lambda Expressions

2007-10-24 Thread Duncan Booth
beginner <[EMAIL PROTECTED]> wrote: > 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 e

Re: Speed of Nested Functions & Lambda Expressions

2007-10-23 Thread Terry Reedy
"Gary Herron" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | beginner wrote: | > 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 f

Re: Speed of Nested Functions & Lambda Expressions

2007-10-23 Thread beginner
On Oct 23, 11:06 am, Gary Herron <[EMAIL PROTECTED]> wrote: > beginner wrote: > > 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 calle

Re: Speed of Nested Functions & Lambda Expressions

2007-10-23 Thread Gary Herron
beginner wrote: > 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

Speed of Nested Functions & Lambda Expressions

2007-10-23 Thread beginner
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