Static variables [was Re: syntax difference]

Gregory Ewing greg.ewing at canterbury.ac.nz
Sat Jun 23 21:58:59 EDT 2018


Bart wrote:
> Wow. (Just think of all the times you write a function containing a neat 
> bunch of local functions, every time it's called it has to create a new 
> function instances for each of those functions, even if they are not used.)

Fortunately, function objects are small and cheap, essentially
just a couple of object references. The overhead of creating one
is probably about the same as creating an empty list. If your
function is complicated enough to benefit from local functions,
the cost is going to be swamped by the rest of the work being
done.

-- 
Greg



More information about the Python-list mailing list