Deque
Applies to: general, python
A deque (double-ended queue) lets you push and pop from both ends in O(1). It works as a stack, a queue, or a sliding window buffer.
from collections import deque
q = deque([1, 2, 3])
q.appendleft(0) # 0 1 2 3
q.pop() # 3