gagsl-py2 at yahoo.com.ar
Thu Sep 27 08:35:08 CEST 2007
En Thu, 27 Sep 2007 01:43:32 -0300, wink <wink at saville.com> escribi�:
> You are most correct, but Queue is slow compared to deque but
> not for the reason I guessed. Apparently it's because deque is
> implemented in C while Queue is in python. Using the program below
> it looks there is about a 35:1 speed difference.
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.
More information about the Python-list