12
Clearing The Deque (exploring Python's deque data structure through a picture story)
(thepythoncodingstack.substack.com)
Welcome to the Python community on the programming.dev Lemmy instance!
Past
November 2023
October 2023
July 2023
August 2023
September 2023
When do I need a doubly-linked list in Python? Whenever I have something where I can often expect to interact with the first and last element of it? Always, because it's more efficient than shifting the entire list around? Something else entirely?
You can use a deque as a stack (First In, Last Out) or as a queue (First In, First Out). Lists are especially inefficient when adding/removing from the beginning of the list, but, for deques, it's a O(1) operation.
https://en.m.wikipedia.org/wiki/Double-ended_queue#Applications