Why doesn't this fail?

Terry Reedy tjreedy at udel.edu
Wed Oct 9 17:15:18 CEST 2002


"Alan Kennedy" <alanmk at hotmail.com> wrote in message
news:3DA438EE.60B2F94A at hotmail.com...
> I'm writing some code that uses threads to iterate over a
> read-only object that is shared between all threads.
>
> The object contains lists of items. The object also has a
> method, which iterates over the lists, using a local variable
> (not an object data member).
>
> I would expect that the local
> variable would be shared between threads. So, without mutual
> exclusion, I expect that using that local variable should cause
> errors in a multi-threaded situation.
>
> But it doesn't.

Local variables must be part of the per-call execution frame.
Otherwise recursion would not be possible (and it wasn't in at least
some early versions of Fortran, as I remember).

TJR





More information about the Python-list mailing list