Dictionaries and Threads
yawyi at gmx.de
Sat May 27 06:39:27 EDT 2000
Aahz Maruch <aahz at netcom.com> wrote:
>In article <392ebd70$0$18389 at personalnews.de.uu.net>,
>Johannes Stezenbach <yawyi at gmx.de> wrote:
>>Why not? The global interpreter lock isn't released in the code of
>>builtin_map() or builtin_reduce(), so no other thread can change the
>>sequence while the map/reduce loop is running.
>IIRC, the global interpreter lock can get released when the function
>gets called; it's possible that the lock can't get released if the
>function is a built-in. In any event, my statement that map() and
>reduce() (and also filter()) are not by definition thread-safe stands.
After sleeping the night over it, I now see that my statement is
rubbish because any number of thread switches can occur while
the function argument to map/reduce is called. So only the
map(None, S) special case is thread save...
More information about the Python-list