pythonmorsels.com

Python Morsels: Stacks and queues in Python (opens in new tab)

Use a Python list for stack operations (last-in, first-out) and a deque from the collections module for queue operations (first-in, first-out). Table of contents Stacks versus Queues Stacks in Python Queues in Python A deque is a "double-ended queue" Stack-like and queue-like operations Stacks versus Queues In Computer Science, stacks and queues are data structures that are optimized to make it inexpensive to remove either the most recently added item or the least recently added item. A queue...

Read the original article
Sign in to keep reading the full article.

Keyboard Shortcuts

Navigation

Next / previous post
j/k
Open post
oorEnter
Preview post
v

Post Actions

Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Save / unsave
s

Recommendations

Add interest / feed
Enter
Not interested
x

Go to

Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Discover
gb
Search
/

General

Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help