Working With Python's deque
Real Python
EDITOR BRIEF
Python's deque is a data structure designed for efficient adding and removing of items from either end. It can be used to build queues and stacks, and it also supports a maxlen setting for keeping only a limited history.
INSIGHTS
This is useful when you need fast insertions and removals without using a regular list for everything. Try replacing a list with deque in a small queue or undo-history project to see the difference.
Learn more with these courses
CodeFriends courses that build on this story. Practice in the browser with nothing to install.
- Python Jump-UpMaster data structures and algorithms in Python, and build your own web crawling tools.Intermediate15 Hours
- Python Programming 101Learn Python in just 20 hours! Kickstart your programming journey with this beginner-friendly course.Beginner20 Hours
- Introduction to Web Development (Light)Master HTML, CSS, and JavaScript in just 10 hours.Beginner10 Hours
COMMENTS
Loading comments…