Queue peek?

MRAB python at mrabarnett.plus.com
Wed Mar 3 02:00:11 CET 2010

John Krukoff wrote:
> On Tue, 2010-03-02 at 22:54 +0100, mk wrote:
> <snip>
>> No need to use synchro primitives like locks?
>> I know that it may work, but that strikes me as somehow wrong... I'm 
>> used to using things like Lock().acquire() and Lock().release() when 
>> accessing shared data structures, whatever they are.
> <snip>
> This is one of those places where the GIL is a good thing, and makes
> your life simpler. You could consider it that the interpreter does the
> locking for you for such primitive operations, if you like.

I suppose it depends on the complexity of the data structure. A dict's
methods are threadsafe, for example, but if you have a data structure
where access leads to multiple method calls then collectively they need
a lock.

More information about the Python-list mailing list