As FIFO data structure you could use next (with corresponding complexity):

  • list: append() amortized O(1) and pop(0) O(n)
  • collections.deque - append() O(1) and popleft() O(1)
  • Queue.queue - get() O(1) and put() O(1) and etc. It is suitable for multi-threaded programming and based on collections.deque internally.
Answer from alex_noname on Stack Overflow
🌐
Python
docs.python.org › 3 › library › queue.html
queue — A synchronized queue class
February 23, 2026 - The module implements three types of queue, which differ only in the order in which the entries are retrieved. In a FIFO queue, the first tasks added are the first retrieved. In a LIFO queue, the most recently added entry is the first retrieved ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › queue-in-python
Queue in Python - GeeksforGeeks
December 11, 2025 - Queue is a linear data structure that stores items in a First In First Out (FIFO) manner. The item that is added first will be removed first. Queues are widely used in real-life scenarios, like ticket booking, or CPU task scheduling, where ...
Discussions

Python Datatype for a fixed-length FIFO - Stack Overflow
I would like to know if there is a native datatype in Python that acts like a fixed-length FIFO buffer. For example, I want do create a length-5 FIFO buffer that is initialized with all zeros. Th... More on stackoverflow.com
🌐 stackoverflow.com
is this a valid implementation of a FIFO queue? : r/algorithms
🌐 r/algorithms
Question about Python Queues (FIFO) enqueue and dequeue methods
you need to store both the first and the last item for quick access. so when you enqueue, you add it at the tail, so first you get the current tail, and add the new node on it, then you set the new qtail to the new node. On the opposite, for dequeue, you remove from the head. so the new head would be the currenthead->next. first we have a special case is the head is also the tail (if there is only one item), that the qhead = qtail if. then, you change the qhead to be the next in line. your queue is implemented as a linked list that allow you to go from the oldest to newest, plus 2 nodes that we keep track, the first and last. you could theorically do without it, but then your queue and dequeue operator would have a different complexity. More on reddit.com
🌐 r/learnprogramming
4
1
October 16, 2019
pyfiq -- Minimal Redis-backed FIFO queues for Python
I love the idea, small and simple. I'll check it out and test it. More on reddit.com
🌐 r/Python
6
16
July 1, 2025
🌐
Python Module of the Week
pymotw.com › 2 › Queue
Queue – A thread-safe FIFO implementation - Python Module of the Week
This example uses a single thread to illustrate that elements are removed from the queue in the same order they are inserted. ... In contrast to the standard FIFO implementation of Queue, the LifoQueue uses last-in, first-out ordering (normally associated with a stack data structure).
🌐
Guru99
guru99.com › home › python › python queue: fifo, lifo example
Python Queue: FIFO, LIFO Example
August 12, 2024 - The module is available by default with python, and you don’t need any additional installation to start working with the queue. There are 2 types of queue FIFO (first in first out) and LIFO (last in first out).
🌐
Medium
basillica.medium.com › working-with-queues-in-python-a-complete-guide-aa112d310542
Working with Queues in Python — A Complete Guide | by Basillica | Medium
March 27, 2024 - In this comprehensive guide, we will cover everything you need to know about using queues in Python. ... A queue is a linear data structure that follows the FIFO principle — the first element added to the queue is the first one to be removed.
🌐
Great Learning
mygreatlearning.com › blog › it/software development › python queue
Python Queue
October 14, 2024 - But, In Python, there are mainly two types of queues that are discussed below: FIFO Queue: FIFO stands for “First In First Out” which means the element that will be inserted first is the element to come out first.
Find elsewhere
🌐
W3Schools
w3schools.com › python › python_dsa_queues.asp
Queues with Python
Python Examples Python Compiler ... Bootcamp Python Certificate Python Training ... A queue is a linear data structure that follows the First-In-First-Out (FIFO) principle....
🌐
w3resource
w3resource.com › python-exercises › data-structures-and-algorithms › python-data-structure-exercise-29.php
Python Data Structure: Create a FIFO queue - w3resource
July 28, 2025 - Write a Python program to create a FIFO queue. ... import queue q = queue.Queue() #insert items at the end of the queue for x in range(4): q.put(str(x)) #remove items from the head of the queue while not q.empty(): print(q.get(), end=" ") print("\n")
🌐
AWS
aws.amazon.com › blogs › developer › using-python-and-amazon-sqs-fifo-queues-to-preserve-message-sequencing
Using Python and Amazon SQS FIFO Queues to Preserve Message Sequencing | AWS Developer Tools Blog
January 16, 2021 - (In Amazon SQS, the queue will be named TradeStatus.fifo.) The application regularly sends trade status received during the trade lifecycle in the queue (for example, trade received, trade checked, trade confirmed, and so on). In the second part, we simulate a client application that gets the trade status to update an internal website or to send status update notifications to other tools. The script stops after the message is read. To accomplish this, you can use the following two Python code examples.
🌐
Real Python
realpython.com › queue-in-python
Python Stacks, Queues, and Priority Queues in Practice – Real Python
December 1, 2023 - Restart the Python interpreter and import your class again to see the updated code in action: ... >>> from queues import Queue >>> fifo = Queue("1st", "2nd", "3rd") >>> len(fifo) 3 >>> for element in fifo: ... print(element) ...
🌐
Software Testing Help
softwaretestinghelp.com › home › python programming for beginners – free python tutorials › python queue tutorial: how to implement and use python queue
Python Queue Tutorial: How To Implement And Use Python Queue
April 1, 2025 - To delete the element in the queue the “ get() ” function is used. It is known as the dequeue operation. The Python queue works on the FIFO ( First In First Out ) principle i.e.
🌐
O'Reilly
oreilly.com › library › view › python-cookbook › 0596001673 › ch17s15.html
Implementing a First-In First-Out Container - Python Cookbook [Book]
July 19, 2002 - You need a container that allows element insertion and removal, in which the first element inserted is also the first to be removed (i.e., a first-in first-out, FIFO, queue). We can use a class to wrap a Pythonic implementation of a linked list:
Authors   Alex MartelliDavid Ascher
Published   2002
Pages   608
🌐
On-systems
on-systems.tech › blog › 126-fifo-queue-in-python
FIFO Queue in Python - Systems and Tech Thoughts
September 24, 2022 - import queueimport queue # A FIFO queue means entries will be received in the order they were enqueued q = queue.Queue() for i in range(5): q.put(i) while not q.empty(): print(q.get()) The following shows the execution of this code in the python ...
🌐
Medium
medium.com › dm03514-tech-blog › python-algorithms-implementing-a-fifo-queue-using-a-linked-list-57cf700a6395
Python Algorithms — Implementing a FIFO Queue Using a Linked List | by dm03514 | Dm03514 Tech Blog | Medium
August 29, 2021 - This is referred to as a “first in first out queue” (FIFO). This post details an implementation of a FIFO queue using a linked list. This post hopes to be a useful algorithm interview study reference. All code is available on github at dm03514/python-algorithms.
🌐
Medium
medium.com › @khasnobis.sanjit890 › linear-data-structure-queue-in-python-fifo-first-in-first-out-bbd03f6b3b0f
Linear Data Structure Queue in python — FIFO — First in First Out | by Sanjit Khasnobis | Medium
September 16, 2023 - This ordering principle is sometimes called FIFO, first-in first-out. It is also known as “first-come first-served. The best example of a queue is the typical line that we all participate when we stand in the payment queue of supermarket or ...
🌐
Medium
medium.com › @shras_a › queue-in-python-34a74641502e
Queue in Python. Queues are fundamental data structures… | by Shravya | Medium
November 14, 2024 - Queue in Python Queues are fundamental data structures that follows the First In, First Out (FIFO) principle, meaning the first element added to the queue will be the first one to be removed. Think …