static statements and thread safety

Eric Snow ericsnowcurrently at
Thu Sep 22 03:45:20 EDT 2011

A recent thread on the python-ideas list got me thinking about the
possibility of a static statement (akin to global and nonlocal).  I am
wondering if an implementation would have to address thread safety

I would expect that static variables would work pretty much the same
way as default arguments, with a list of names on the code object and
a list of values on the function object.  And I would guess that the
values from the static variables would get updated on the function
object at the end of the call.  If multiple threads are executing the
function at the same time won't there be a problem with that
end-of-call update?


p.s. It probably shows that I haven't done a lot of thread-related
programming, so perhaps this is not a hard question.

More information about the Python-list mailing list