title: Queue.Queue vs. collections.deque
body: <p>I need a queue which multiple threads can put stuff into, and multiple threads may read from.</p>
  <p>Python has at least two queue classes, <code>Queue.Queue</code> and <code>collections.deque</code>, with the former seemingly using the latter internally. Both claim to be thread-safe in the documentation.</p>
  <p>However, the Queue docs also state:</p>
  <blockquote>
  <p>collections.deque is an alternative
  implementation of unbounded queues
  with fast atomic append() and
  popleft() operations <strong>that do not
  require locking.</strong></p>
  </blockquote>
  <p>Which I guess I don't quite unterstand: Does this mean deque isn't fully thread-safe after all?</p>
  <p>If it is, I may not fully understand the difference between the two classes. I can see that Queue adds blocking functionality. On the other hand, it loses some deque features like support for the in-operator.</p>
  <p>Accessing the internal deque object directly, is</p>
  <blockquote>
  <p>x in Queue().deque</p>
  </blockquote>
  <p>thread-safe?</p>
  <p>Also, <strong>why does Queue employ a mutex for it's operations when deque is thread-safe already?</strong></p>