René's URL Explorer Experiment


Title: Python's deque: Implement Efficient Queues and Stacks – Real Python

Open Graph Title: Python's deque: Implement Efficient Queues and Stacks – Real Python

Description: Use a Python deque to efficiently append and pop elements from both ends of a sequence, build queues and stacks, and set maxlen for history buffers.

Open Graph Description: Use a Python deque to efficiently append and pop elements from both ends of a sequence, build queues and stacks, and set maxlen for history buffers.

Mail addresses
?subject=Python article for you&body=Python's deque: Implement Efficient Queues and Stacks on Real Python https://realpython.com/python-deque/

Opengraph URL: https://realpython.com/python-deque/

X: @realpython

direct link

Domain: realpython.com


Hey, it has json ld scripts:
{
  "@context": "http://schema.org",
  "@type": "Article",
  "headline": "Python's deque: Implement Efficient Queues and Stacks",
  "image": {
    "@type": "ImageObject",
    "url": "https://files.realpython.com/media/Collections.deque_Watermarked.066fbf353cb4.jpg",
    "width": 1920,
    "height": 1080
  },
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "https://realpython.com/python-deque/",
    "lastReviewed": "2026-01-12",
    "author": {
      "@type": "Person",
      "name": "Leodanis Pozo Ramos",
      "image": "https://realpython.com/cdn-cgi/image/width=862,height=862,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Perfil_final1.9f896bc212f6.jpg",
      "url": "https://realpython.com/team/lpozoramos/",
      "affiliation": {
        "@type": "Organization",
        "@id": "https://realpython.com/#organization",
        "name": "Real Python",
        "url": "https://realpython.com",
        "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
      }
    },
    "reviewedBy": [
      {
        "@type": "Person",
        "name": "Aldren Santos",
        "image": "https://realpython.com/cdn-cgi/image/width=500,height=500,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Aldren_Santos_Real_Python.6b0861d8b841.png",
        "url": "https://realpython.com/team/asantos/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Brenda Weleschuk",
        "image": "https://realpython.com/cdn-cgi/image/width=320,height=320,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/IMG_3324_1.50b309355fc1.jpg",
        "url": "https://realpython.com/team/bweleschuk/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Bartosz Zaczy\u0144ski",
        "image": "https://realpython.com/cdn-cgi/image/width=1694,height=1694,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/coders_lab_2109368.259b1599fbee.jpg",
        "url": "https://realpython.com/team/bzaczynski/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Joanna Jablonski",
        "image": "https://realpython.com/cdn-cgi/image/width=800,height=800,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/jjablonksi-avatar.e37c4f83308e.jpg",
        "url": "https://realpython.com/team/jjablonski/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Jacob Schmitt",
        "image": "https://realpython.com/cdn-cgi/image/width=400,height=400,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/profile-small_js.2f4d0d8da1ca.jpg",
        "url": "https://realpython.com/team/jschmitt/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Martin Breuss",
        "image": "https://realpython.com/cdn-cgi/image/width=456,height=456,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/martin_breuss_python_square.efb2b07faf9f.jpg",
        "url": "https://realpython.com/team/mbreuss/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      }
    ]
  },
  "datePublished": "2026-01-12T14:00:00+00:00",
  "dateModified": "2026-01-12T14:09:26.131860+00:00",
  "publisher": {
    "@type": "Organization",
    "@id": "https://realpython.com/#organization",
    "name": "Real Python",
    "url": "https://realpython.com",
    "logo": {
      "@type": "ImageObject",
      "url": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png",
      "width": 512,
      "height": 512
    },
    "description": "Real Python is a leading provider of online Python education and one of the largest language-specific online communities for software developers. It publishes high-quality learning resources, such as tutorials, books, and courses to an audience of millions of developers, data scientists, and machine learning engineers each month.",
    "slogan": "Become a Python Expert",
    "email": "info@realpython.com",
    "sameAs": [
      "https://github.com/realpython",
      "https://www.youtube.com/realpython",
      "https://twitter.com/realpython",
      "https://x.com/realpython",
      "https://www.linkedin.com/company/realpython-com/",
      "https://www.facebook.com/learnrealpython",
      "https://www.instagram.com/realpython",
      "https://www.tiktok.com/@realpython.com"
    ]
  },
  "author": {
    "@type": "Person",
    "name": "Leodanis Pozo Ramos",
    "image": "https://realpython.com/cdn-cgi/image/width=862,height=862,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Perfil_final1.9f896bc212f6.jpg",
    "url": "https://realpython.com/team/lpozoramos/",
    "affiliation": {
      "@type": "Organization",
      "@id": "https://realpython.com/#organization",
      "name": "Real Python",
      "url": "https://realpython.com",
      "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
    }
  },
  "description": "Use a Python deque to efficiently append and pop elements from both ends of a sequence, build queues and stacks, and set maxlen for history buffers.",
  "hasPart": {
    "@type": "FAQPage",
    "mainEntity": [
      {
        "@type": "Question",
        "name": "Why should you use deque instead of list for queues or stacks?",
        "acceptedAnswer": {
          "@type": "Answer",
          "text": "

Use deque when you need O(1) appends and pops on both ends. It’s designed to avoid the costly shifting and memory reallocation you can run into with a list. You can build a FIFO queue with .append() and .popleft(), or a LIFO stack with .append() and .pop().

" } }, { "@type": "Question", "name": "When should you stick with list instead of deque?", "acceptedAnswer": { "@type": "Answer", "text": "

Stick with list when you need fast random indexing and slicing, or when you want in-place sorting with list.sort(). With deque, indexing is O(n) and slicing isn’t available.

" } }, { "@type": "Question", "name": "How do you create a fixed-size deque and what happens when it fills up?", "acceptedAnswer": { "@type": "Answer", "text": "

You pass maxlen when you construct it, for example: deque(iterable, maxlen=n). When you append to a full deque, it automatically discards items from the opposite end, and you can check the limit with .maxlen.

" } }, { "@type": "Question", "name": "Are deque operations thread-safe?", "acceptedAnswer": { "@type": "Answer", "text": "

In CPython, .append(), .appendleft(), .pop(), .popleft(), and len() are thread-safe, so you can push and pop from multiple threads safely. For real-world multithreaded programs—especially when you need blocking behavior—use queue.Queue.

" } } ] } }

authorReal Python
twitter:cardsummary_large_image
twitter:imagehttps://files.realpython.com/media/Collections.deque_Watermarked.066fbf353cb4.jpg
og:imagehttps://files.realpython.com/media/Collections.deque_Watermarked.066fbf353cb4.jpg
twitter:creator@realpython
og:typearticle

Links:

https://realpython.com/
Start Herehttps://realpython.com/start-here/
Learn Python https://realpython.com/python-deque/
Python Tutorials →In-depth articles and video courseshttps://realpython.com/search?kind=article&kind=course&order=newest
Learning Paths →Guided study plans for accelerated learninghttps://realpython.com/learning-paths/
Quizzes & Exercises →Check your learning progresshttps://realpython.com/quizzes/
Browse Topics →Focus on a specific area or skill levelhttps://realpython.com/tutorials/all/
Community Chat →Learn with other Pythonistashttps://realpython.com/community/
Office Hours →Live Q&A calls with Python expertshttps://realpython.com/office-hours/
Podcast →Hear what’s new in the world of Pythonhttps://realpython.com/podcasts/rpp/
Books →Round out your knowledge and learn offlinehttps://realpython.com/products/books/
Reference →Concise definitions for common Python termshttps://realpython.com/ref/
Code Mentor →BetaPersonalized code assistance & learning toolshttps://realpython.com/mentor/
Unlock All Content →https://realpython.com/account/join/
More https://realpython.com/python-deque/
Learner Storieshttps://realpython.com/learner-stories/
Python Newsletterhttps://realpython.com/newsletter/
Python Job Boardhttps://www.pythonjobshq.com
Meet the Teamhttps://realpython.com/team/
Become a Tutorial Writerhttps://realpython.com/write-for-us/
Become a Video Instructorhttps://realpython.com/become-an-instructor/
Searchhttps://realpython.com/search
https://realpython.com/search
Joinhttps://realpython.com/account/join/
Sign‑Inhttps://realpython.com/account/login/?next=%2Fpython-deque%2F
Browse Topicshttps://realpython.com/tutorials/all/
Guided Learning Pathshttps://realpython.com/learning-paths/
Basicshttps://realpython.com/search?level=basics
Intermediatehttps://realpython.com/search?level=intermediate
Advancedhttps://realpython.com/search?level=advanced
aihttps://realpython.com/tutorials/ai/
algorithmshttps://realpython.com/tutorials/algorithms/
apihttps://realpython.com/tutorials/api/
best-practiceshttps://realpython.com/tutorials/best-practices/
careerhttps://realpython.com/tutorials/career/
communityhttps://realpython.com/tutorials/community/
databaseshttps://realpython.com/tutorials/databases/
data-sciencehttps://realpython.com/tutorials/data-science/
data-structureshttps://realpython.com/tutorials/data-structures/
data-vizhttps://realpython.com/tutorials/data-viz/
devopshttps://realpython.com/tutorials/devops/
djangohttps://realpython.com/tutorials/django/
dockerhttps://realpython.com/tutorials/docker/
editorshttps://realpython.com/tutorials/editors/
flaskhttps://realpython.com/tutorials/flask/
front-endhttps://realpython.com/tutorials/front-end/
gamedevhttps://realpython.com/tutorials/gamedev/
guihttps://realpython.com/tutorials/gui/
machine-learninghttps://realpython.com/tutorials/machine-learning/
newshttps://realpython.com/tutorials/news/
numpyhttps://realpython.com/tutorials/numpy/
projectshttps://realpython.com/tutorials/projects/
pythonhttps://realpython.com/tutorials/python/
stdlibhttps://realpython.com/tutorials/stdlib/
testinghttps://realpython.com/tutorials/testing/
toolshttps://realpython.com/tutorials/tools/
web-devhttps://realpython.com/tutorials/web-dev/
web-scrapinghttps://realpython.com/tutorials/web-scraping/
Table of Contentshttps://realpython.com/python-deque/#toc
Get Started With Python’s dequehttps://realpython.com/python-deque/#get-started-with-pythons-deque
Pop and Append Items With Efficient deque Methodshttps://realpython.com/python-deque/#pop-and-append-items-with-efficient-deque-methods
Access Random Items in a dequehttps://realpython.com/python-deque/#access-random-items-in-a-deque
Build Efficient Queues With dequehttps://realpython.com/python-deque/#build-efficient-queues-with-deque
Explore Other Features and Methods of dequehttps://realpython.com/python-deque/#explore-other-features-and-methods-of-deque
Limiting the Number of Items: maxlenhttps://realpython.com/python-deque/#limiting-the-number-of-items-maxlen
Rotating the Items: .rotate()https://realpython.com/python-deque/#rotating-the-items-rotate
Adding Several Items at Once: .extendleft()https://realpython.com/python-deque/#adding-several-items-at-once-extendleft
Use Sequence-Like Features of dequehttps://realpython.com/python-deque/#use-sequence-like-features-of-deque
Put Python’s deque Into Actionhttps://realpython.com/python-deque/#put-pythons-deque-into-action
Keeping a Page Historyhttps://realpython.com/python-deque/#keeping-a-page-history
Sharing Data Between Threadshttps://realpython.com/python-deque/#sharing-data-between-threads
Emulating the tail Commandhttps://realpython.com/python-deque/#emulating-the-tail-command
Conclusionhttps://realpython.com/python-deque/#conclusion
Frequently Asked Questionshttps://realpython.com/python-deque/#frequently-asked-questions
https://realpython.com/feedback/survey/article/python-deque/liked/?from=article-sidebar
https://realpython.com/feedback/survey/article/python-deque/disliked/?from=article-sidebar
Leodanis Pozo Ramoshttps://realpython.com/python-deque/#author
https://realpython.com/python-deque/#reader-comments
intermediatehttps://realpython.com/tutorials/intermediate/
data-structureshttps://realpython.com/tutorials/data-structures/
pythonhttps://realpython.com/tutorials/python/
stdlibhttps://realpython.com/tutorials/stdlib/
Get Started With Python’s dequehttps://realpython.com/python-deque/#get-started-with-pythons-deque
Pop and Append Items With Efficient deque Methodshttps://realpython.com/python-deque/#pop-and-append-items-with-efficient-deque-methods
Access Random Items in a dequehttps://realpython.com/python-deque/#access-random-items-in-a-deque
Build Efficient Queues With dequehttps://realpython.com/python-deque/#build-efficient-queues-with-deque
Explore Other Features and Methods of dequehttps://realpython.com/python-deque/#explore-other-features-and-methods-of-deque
Limiting the Number of Items: maxlenhttps://realpython.com/python-deque/#limiting-the-number-of-items-maxlen
Rotating the Items: .rotate()https://realpython.com/python-deque/#rotating-the-items-rotate
Adding Several Items at Once: .extendleft()https://realpython.com/python-deque/#adding-several-items-at-once-extendleft
Use Sequence-Like Features of dequehttps://realpython.com/python-deque/#use-sequence-like-features-of-deque
Put Python’s deque Into Actionhttps://realpython.com/python-deque/#put-pythons-deque-into-action
Keeping a Page Historyhttps://realpython.com/python-deque/#keeping-a-page-history
Sharing Data Between Threadshttps://realpython.com/python-deque/#sharing-data-between-threads
Emulating the tail Commandhttps://realpython.com/python-deque/#emulating-the-tail-command
Conclusionhttps://realpython.com/python-deque/#conclusion
Frequently Asked Questionshttps://realpython.com/python-deque/#frequently-asked-questions
Remove adshttps://realpython.com/account/join/
Click here to download the free sample codehttps://realpython.com/bonus/python-deque-code/
https://realpython.com/quizzes/python-deque/
Python's deque: Implement Efficient Queues and Stackshttps://realpython.com/quizzes/python-deque/
https://realpython.com/python-deque/#get-started-with-pythons-deque
listhttps://realpython.com/python-list/
Big O notationhttps://en.wikipedia.org/wiki/Big_O_notation
time complexityhttps://wiki.python.org/moin/TimeComplexity
.append()https://realpython.com/python-append/
methodshttps://realpython.com/ref/glossary/method/
stackshttps://en.wikipedia.org/wiki/Stack_(abstract_data_type)
queueshttps://en.wikipedia.org/wiki/Queue_(abstract_data_type)
dequehttps://docs.python.org/3/library/collections.html#collections.deque
collectionshttps://realpython.com/python-collections-module/
Python 2.4https://docs.python.org/3/whatsnew/2.4.html#new-improved-and-deprecated-modules
sequencehttps://realpython.com/ref/glossary/sequence/
data structurehttps://realpython.com/ref/glossary/data-structure/
stackshttps://realpython.com/ref/glossary/stack/
queueshttps://realpython.com/ref/glossary/queue/
double-ended queuehttps://en.wikipedia.org/wiki/Double-ended_queue
implementedhttps://github.com/python/cpython/blob/23acadcc1c75eb74b2459304af70d97a35001b34/Modules/_collectionsmodule.c#L34
doubly linked listhttps://realpython.com/linked-lists-python/#how-to-use-doubly-linked-lists
thread-safehttps://en.wikipedia.org/wiki/Thread_safety
data typehttps://realpython.com/python-data-types/
mutablehttps://realpython.com/ref/glossary/mutable/
membership operationshttps://realpython.com/python-in-operator/
in operatorhttps://realpython.com/ref/keywords/in/
indexinghttps://realpython.com/ref/glossary/indexing/
slicinghttps://realpython.com/ref/glossary/slicing/
built-in functionshttps://realpython.com/python-built-in-functions/
sequenceshttps://realpython.com/python-sequences/
iterableshttps://realpython.com/python-iterators-iterables/
len()https://realpython.com/len-python-function/
sorted()https://realpython.com/python-sort/
reversed()https://realpython.com/python-reverse-list/
in-placehttps://en.wikipedia.org/wiki/In-place_algorithm
iterationhttps://realpython.com/ref/glossary/iteration/
picklehttps://realpython.com/python-pickle-module/
thread-safehttps://realpython.com/python-thread-lock/
iterablehttps://realpython.com/ref/glossary/iterable/
argumenthttps://realpython.com/ref/glossary/argument/
optional argumentshttps://realpython.com/python-optional-arguments/
numberhttps://realpython.com/python-numbers/
maxlenhttps://docs.python.org/3/library/collections.html#collections.deque.maxlen
setshttps://realpython.com/python-sets/
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-deque/#pop-and-append-items-with-efficient-deque-methods
.popleft()https://docs.python.org/3/library/collections.html#collections.deque.popleft
.appendleft()https://docs.python.org/3/library/collections.html#collections.deque.appendleft
.append()https://docs.python.org/3/library/collections.html#collections.deque.append
.pop()https://docs.python.org/3/library/collections.html#collections.deque.pop
linked listhttps://realpython.com/linked-lists-python/
pointerhttps://realpython.com/pointers-in-python/
sequencehttps://realpython.com/ref/glossary/sequence/
run the scripthttps://realpython.com/run-python-scripts/
https://realpython.com/python-deque/#access-random-items-in-a-deque
.insert(i, value)https://docs.python.org/3/library/collections.html#collections.deque.insert
.remove(value)https://docs.python.org/3/library/collections.html#collections.deque.remove
ValueErrorhttps://realpython.com/ref/builtin-exceptions/valueerror/
indexinghttps://realpython.com/ref/glossary/indexing/
delhttps://realpython.com/python-del-statement/
keywordhttps://realpython.com/python-keywords/
slicinghttps://realpython.com/ref/glossary/slicing/
slicehttps://realpython.com/ref/glossary/slice/
TypeErrorhttps://realpython.com/ref/builtin-exceptions/typeerror/
arrayshttps://en.wikipedia.org/wiki/Array_data_structure
interpreterhttps://realpython.com/ref/glossary/interpreter/
profilehttps://realpython.com/python-profiling/
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-deque/#build-efficient-queues-with-deque
abstract data types (ADT)https://en.wikipedia.org/wiki/Abstract_data_type
standard libraryhttps://realpython.com/ref/glossary/standard-library/
queuehttps://docs.python.org/3/library/queue.html#module-queue
modulehttps://realpython.com/ref/glossary/module/
collectionshttps://realpython.com/ref/glossary/collection/
FIFOhttps://en.wikipedia.org/wiki/FIFO_(computing_and_electronics)
.append()https://docs.python.org/3/library/collections.html#collections.deque.append
.popleft()https://docs.python.org/3/library/collections.html#collections.deque.popleft
APIhttps://realpython.com/ref/glossary/api/
classeshttps://realpython.com/python-classes/
adapter design patternhttps://sourcemaking.com/design_patterns/adapter
special methodshttps://realpython.com/python-magic-methods/
.__len__()https://docs.python.org/3/reference/datamodel.html#object.__len__
.__contains__()https://docs.python.org/3/reference/datamodel.html#object.__contains__
.__iter__()https://docs.python.org/3/reference/datamodel.html#object.__iter__
.__reversed__()https://docs.python.org/3/reference/datamodel.html#object.__reversed__
.__repr__()https://docs.python.org/3/reference/datamodel.html#object.__repr__
.__repr__()https://realpython.com/python-repr-vs-str/
string representationhttps://realpython.com/ref/glossary/string-representation/
returnhttps://realpython.com/python-return-statement/
interactive shellhttps://realpython.com/interacting-with-python/
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-deque/#explore-other-features-and-methods-of-deque
https://realpython.com/python-deque/#limiting-the-number-of-items-maxlen
Nonehttps://realpython.com/null-in-python/
iterablehttps://realpython.com/ref/glossary/iterable/
ValueErrorhttps://realpython.com/ref/builtin-exceptions/valueerror/
https://realpython.com/python-deque/#rotating-the-items-rotate
.rotate()https://docs.python.org/3/library/collections.html#collections.deque.rotate
https://realpython.com/python-deque/#adding-several-items-at-once-extendleft
.extend()https://docs.python.org/3/library/collections.html#collections.deque.extend
extendleft()https://docs.python.org/3/library/collections.html#collections.deque.extendleft
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-deque/#use-sequence-like-features-of-deque
sequenceshttps://docs.python.org/3/library/stdtypes.html#common-sequence-operations
mutable sequenceshttps://docs.python.org/3/library/stdtypes.html#mutable-sequence-types
operatorhttps://realpython.com/python-operators-expressions/
.clear()https://docs.python.org/3/library/collections.html#collections.deque.clear
.copy()https://docs.python.org/3/library/collections.html#collections.deque.copy
shallow copyhttps://realpython.com/ref/glossary/shallow-copy/
.count(value)https://docs.python.org/3/library/collections.html#collections.deque.count
.index(value)https://docs.python.org/3/library/collections.html#collections.deque.index
.reverse()https://docs.python.org/3/library/collections.html#collections.deque.reverse
ValueErrorhttps://realpython.com/ref/builtin-exceptions/valueerror/
sorted()https://realpython.com/ref/builtin-functions/sorted/
https://realpython.com/python-deque/#put-pythons-deque-into-action
circular buffershttps://en.wikipedia.org/wiki/Circular_buffer
web servicehttps://en.wikipedia.org/wiki/Web_service
https://realpython.com/python-deque/#keeping-a-page-history
scrapeshttps://realpython.com/python-web-scraping-practical-introduction/
https://realpython.com/python-deque/#sharing-data-between-threads
multithreadedhttps://realpython.com/intro-to-python-threading/
Raymond Hettingerhttps://twitter.com/raymondh
Sourcehttps://bugs.python.org/msg199368
code editorhttps://realpython.com/python-ides-code-editors-guide/
random.randint()https://docs.python.org/3/library/random.html#random.randint
while loophttps://realpython.com/python-while-loop/
randomhttps://realpython.com/python-random/
globalhttps://realpython.com/python-scope-legb-rule/#modules-the-global-scope
lockhttps://realpython.com/python-thread-lock/
helper functionhttps://realpython.com/python-double-underscore/#helper-functions
try … excepthttps://realpython.com/python-exceptions/#the-try-and-except-block-handling-exceptions
statementhttps://realpython.com/ref/glossary/statement/
namespacehttps://realpython.com/python-namespaces-scope/
global variablehttps://realpython.com/python-use-global-variable-in-function/
best practicehttps://realpython.com/ref/best-practices/
concurrentlyhttps://realpython.com/ref/glossary/concurrency/
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-deque/#emulating-the-tail-command
tail commandhttps://en.wikipedia.org/wiki/Tail_(Unix)
Unix-likehttps://en.wikipedia.org/wiki/Unix-like
stringhttps://realpython.com/python-strings/
deque recipeshttps://docs.python.org/3/library/collections.html#deque-recipes
https://realpython.com/python-deque/#conclusion
Python’s collections modulehttps://realpython.com/python-collections-module/
dequehttps://docs.python.org/3/library/collections.html#collections.deque
Click here to download the free sample codehttps://realpython.com/bonus/python-deque-code/
https://realpython.com/python-deque/#frequently-asked-questions
https://realpython.com/quizzes/python-deque/
Python's deque: Implement Efficient Queues and Stackshttps://realpython.com/quizzes/python-deque/
https://realpython.com/feedback/survey/article/python-deque/liked/?from=article-footer
https://realpython.com/feedback/survey/article/python-deque/disliked/?from=article-footer
https://realpython.com/team/lpozoramos/
» More about Leodanishttps://realpython.com/team/lpozoramos/
https://realpython.com/team/asantos/
Aldrenhttps://realpython.com/team/asantos/
https://realpython.com/team/bweleschuk/
Brendahttps://realpython.com/team/bweleschuk/
https://realpython.com/team/bzaczynski/
Bartoszhttps://realpython.com/team/bzaczynski/
https://realpython.com/team/jjablonski/
Joannahttps://realpython.com/team/jjablonski/
https://realpython.com/team/jschmitt/
Jacobhttps://realpython.com/team/jschmitt/
https://realpython.com/team/mbreuss/
Martinhttps://realpython.com/team/mbreuss/
Level Up Your Python Skills »https://realpython.com/account/join/?utm_source=rp_article_footer&utm_content=python-deque
Level Up Your Python Skills »https://realpython.com/account/join/?utm_source=rp_article_footer&utm_content=python-deque
https://realpython.com/feedback/survey/article/python-deque/liked/?from=article-comments
https://realpython.com/feedback/survey/article/python-deque/disliked/?from=article-comments
LinkedInhttps://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Frealpython.com%2Fpython-deque%2F
Twitterhttps://twitter.com/intent/tweet/?text=Interesting%20Python%20article%20on%20%40realpython%3A%20Python%27s%20deque%3A%20Implement%20Efficient%20Queues%20and%20Stacks&url=https%3A%2F%2Frealpython.com%2Fpython-deque%2F
Blueskyhttps://bsky.app/intent/compose?text=Interesting%20Python%20article%20on%20%40realpython.com%3A%20Python%27s%20deque%3A%20Implement%20Efficient%20Queues%20and%20Stacks%20https%3A%2F%2Frealpython.com%2Fpython-deque%2F
Facebookhttps://facebook.com/sharer/sharer.php?u=https%3A%2F%2Frealpython.com%2Fpython-deque%2F
Get tips for asking good questionshttps://realpython.com/python-beginner-tips/#tip-9-ask-good-questions
get answers to common questions in our support portalhttps://support.realpython.com
Real Python Community Chathttps://realpython.com/community/
“Office Hours” Live Q&A Sessionhttps://realpython.com/office-hours/
intermediatehttps://realpython.com/tutorials/intermediate/
data-structureshttps://realpython.com/tutorials/data-structures/
pythonhttps://realpython.com/tutorials/python/
stdlibhttps://realpython.com/tutorials/stdlib/
The Python heapq Module: Using Heaps and Priority Queueshttps://realpython.com/python-heapq-module/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-deque
Bitwise Operators in Pythonhttps://realpython.com/python-bitwise-operators/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-deque
Primer on Python Decoratorshttps://realpython.com/primer-on-python-decorators/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-deque
Pointers in Python: What's the Point?https://realpython.com/pointers-in-python/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-deque
Python's Counter: The Pythonic Way to Count Objectshttps://realpython.com/python-counter/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-deque
https://realpython.com/account/signup/?intent=continue_reading&utm_source=rp&utm_medium=web&utm_campaign=rwn&utm_content=v1&next=%2Fpython-deque%2F
Continue »https://realpython.com/account/signup/?intent=continue_reading&utm_source=rp&utm_medium=web&utm_campaign=rwn&utm_content=v1&next=%2Fpython-deque%2F
Sign-Inhttps://realpython.com/account/login/?next=/python-deque/
Start Herehttps://realpython.com/start-here/
Learning Resourceshttps://realpython.com/search
Code Mentorhttps://realpython.com/mentor/
Python Referencehttps://realpython.com/ref/
Python Cheat Sheethttps://realpython.com/cheatsheets/python/
Support Centerhttps://support.realpython.com/
Learning Pathshttps://realpython.com/learning-paths/
Quizzes & Exerciseshttps://realpython.com/quizzes/
Browse Topicshttps://realpython.com/tutorials/all/
Live Courseshttps://realpython.com/live/
Bookshttps://realpython.com/books/
Podcasthttps://realpython.com/podcasts/rpp/
Newsletterhttps://realpython.com/newsletter/
Community Chathttps://realpython.com/community/
Office Hourshttps://realpython.com/office-hours/
Learner Storieshttps://realpython.com/learner-stories/
Plans & Pricinghttps://realpython.com/account/join/
Team Planshttps://realpython.com/account/join-team/
For Businesshttps://realpython.com/account/join-team/inquiry/
For Schoolshttps://realpython.com/account/join-team/education-inquiry/
Reviewshttps://realpython.com/learner-stories/
About Ushttps://realpython.com/about/
Teamhttps://realpython.com/team/
Mission & Valueshttps://realpython.com/mission/
Editorial Guidelineshttps://realpython.com/editorial-guidelines/
Sponsorshipshttps://realpython.com/sponsorships/
Careershttps://realpython.workable.com
Press Kithttps://realpython.com/media-kit/
Merchhttps://realpython.com/merch
https://www.youtube.com/realpython
https://x.com/realpython
https://www.linkedin.com/company/realpython-com
https://www.facebook.com/LearnRealPython
https://github.com/realpython/
Privacy Policyhttps://realpython.com/privacy-policy/
Terms of Usehttps://realpython.com/terms/
Securityhttps://realpython.com/security/
Contacthttps://realpython.com/contact/
https://realpython.com/

Viewport: width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover

Robots: max-image-preview:large


URLs of crawlers that visited me.