skip at pobox.com skip at pobox.com
Mon Dec 1 19:06:02 CET 2008

    Neal> I noticed in some profiling, that it seems that:

    Neal> def Func ():
    Neal>   def something():
    Neal>     ...

    Neal> It appears that if Func is called many times, this nested func
    Neal> definition will cause significant overhead.  Is this true?  I
    Neal> guess I've become accustomed to decent compilers performing
    Neal> reasonable transformations and so have tended to write code for
    Neal> clarity.

It could.  OTOH, the code object which implements the something body is
stored as a local var (or a constant, can't remember off the top of my
head), so it's not compiled over and over again.

Skip Montanaro - skip at pobox.com - http://smontanaro.dyndns.org/

More information about the Python-list mailing list