Neal Becker wrote:
Arnaud Delobelle wrote:

Neal Becker <[EMAIL PROTECTED]> writes:

I noticed in some profiling, that it seems that:

def Func ():
  def something():
    ...

It appears that if Func is called many times, this nested func
definition will cause significant overhead.  Is this true?  I guess
I've become accustomed to decent compilers performing reasonable
transformations and so have tended to write code for clarity.
If something() can be defined outside Func(), how is it clearer to
define it inside?

If it's only used inside.

I, for one, find that significantly less clear. I only expect functions to be defined inside of functions if they are going to use lexical scoping for some reason. If I read your code, I'd probably waste a good five minutes trying to figure out what part of the local scope you were using before I would conclude that you just did it because you thought it looked better.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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

Reply via email to