A queue is similar to a stack in that is an ordered collection of objects. The order is different though, it is First-In/First-Out (FIFO). This is like a line-up at a bank. For single threaded Python programs you can use either the built-in list
type or collections.deque
for a FIFO queue. For concurrent code, use either the queue.Queue
or multiprocessing.Queue
objects for multi-threaded or multi-processing, respectively.
Here are resources and additional documentation about queue, multiprocessing, concurrency, and pickle:
- collections – Container Datatypes: deque objects | Python Documentation
- queue – A synchronized queue class: Queue | Python Documentation
- multiprocessing – Process-based parallelism: Queue | Python Documentation
- What Is the Python Global Interpreter Lock (GIL) | Real Python Article
- Speed Up Python With Concurrency | Real Python Course
- The Python pickle Module: How to Persist Objects in Python | Real Python Article