static statements and thread safety
python at mrabarnett.plus.com
Thu Sep 22 11:19:04 EDT 2011
On 22/09/2011 08:45, Eric Snow wrote:
> 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?
It's no different from using a global, except that it's not in the
global (module) namespace, but attached to a function object.
> 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