Asynchronous Messaging

wink wink at saville.com
Thu Sep 27 23:52:57 EDT 2007


>
> That't not the reason. A Queue is built around a container, and it happens
> to be a deque in the default implementation. But the important thing is
> that a Queue is a synchronized object - it performs the necesary
> synchronization to ensure proper operation even from multiple threads
> attempting to use it at the same time.
> So your comparison is meaningless, apart from telling that using mutexes
> is not cheap.
>
> --
> Gabriel Genellina

Interesting, from the documentation for deque says;
"Deques support thread-safe, ..." which would seem to
imply a mutex of some sort would be used. But in
looking at collectionsmodule.c for 2.5.1 I don't see
any mutex which would seem to imply there is one
place else, maybe the GIL, or the documentation is
incorrect.

On the other hand looking at the code in Queue.py there
is a more code plus the not_full Condition variable plus
the call to _put (which is a call to the deque.append)
plus a notify on the not_empty conditional, so it's not
surprising it's slower.

If and when I think Queue is a performance impediment
to an mproc I'll take another look at it, for now lots
of things to learn.

Thanks,

Wink




More information about the Python-list mailing list