Re: threads, mutual exclusion, and lists

2007-08-16 Thread Martin v. Löwis
>> Why do you think they are not? > > Because they aren't. You even mentioned that a few operations that > aren't atomic. OTOH, the OP specifically asked for .append() and .pop(), which are atomic. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: threads, mutual exclusion, and lists

2007-08-16 Thread Matt McCredie
> Why do you think they are not? Because they aren't. You even mentioned that a few operations that aren't atomic. If operations are atomic it isn't necessarily because of the design of the list, but the design of CPython. More specifically the GIL. I don't mean to imply that you can't get a multi

Re: threads, mutual exclusion, and lists

2007-08-16 Thread Martin v. Löwis
>> My question is -- are python list operations atomic? If they are not, >> then I assume I need to put some mutual exclusion around the append() >> and pop() calls ? > > They are not, but there is one included in the standard library: > http://docs.python.org/dev/lib/module-Queue.html Why do you

Re: threads, mutual exclusion, and lists

2007-08-15 Thread Matt McCredie
> My question is -- are python list operations atomic? If they are not, > then I assume I need to put some mutual exclusion around the append() > and pop() calls ? They are not, but there is one included in the standard library: http://docs.python.org/dev/lib/module-Queue.html Matt -- http://mai

Re: threads, mutual exclusion, and lists

2007-08-15 Thread Martin v. Löwis
> I have two threads that share a python list. One thread adds to the > list with append(), the other thread removes items with pop(). > > My question is -- are python list operations atomic? Yes, they are in the current implementation of CPython (all versions). Notice that not *all* operations a

Re: threads, mutual exclusion, and lists

2007-08-15 Thread [EMAIL PROTECTED]
On Aug 15, 1:36 pm, Scott <[EMAIL PROTECTED]> wrote: > I have two threads that share a python list. One thread adds to the > list with append(), the other thread removes items with pop(). > > My question is -- are python list operations atomic? If they are not, > then I assume I need to put some mu

threads, mutual exclusion, and lists

2007-08-15 Thread Scott
I have two threads that share a python list. One thread adds to the list with append(), the other thread removes items with pop(). My question is -- are python list operations atomic? If they are not, then I assume I need to put some mutual exclusion around the append() and pop() calls ? Thanks,