0

In python3.7 there are two options for an off-the-shelf FIFO queue object:

  • queue.Queue
  • queue.SimpleQueue

However, all that the docs say about a SimpleQueue is that:

Constructor for an unbounded FIFO queue. Simple queues lack advanced functionality such as task tracking. New in version 3.7.

What would be a functional difference between then two?

1
  • 1
    in your link you can see what method has Queue and SImpleQueue. SimpleQueue doesn't have join(), full() and task_done() - so you can't block queue. And it doesn't have maxsize so you can't limit its size. Commented Mar 5, 2020 at 2:01

1 Answer 1

4

Literally what the docs you quoted tell you (the details can be gleaned by comparing the available methods):

  1. SimpleQueue is always unbounded (Queue is optionally bounded); they removed the full method (because it can never be full)
  2. SimpleQueue doesn't do task tracking, so it doesn't provide task_done (for consumers to indicate a task has been completed) or join (to allow a thread to block until all items put have had a matching task_done call)

This simplifies a lot of the code by dropping support for comparatively rare scenarios (I've almost never seen anyone use task_done or join, and when they do, it's often buggy, with exceptions potentially bypassing a task_done, making join block forever), improving performance a bit by side-effect.

Side-note: If you don't actually need the blocking features at all, you can skip the queue module and just use collections.deque. It's still thread-safe and atomic for appends and pops from either end, it just doesn't provide the ability to do a blocking get when the deque is empty, in exchange for being much lower overhead (implemented entirely in C, with no supplementary locking like queue classes).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.