Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Tips and Traps¶
A deque is implemented via the circular queue data structure and it has O(1) time complexity appending from both ends.
Unlike list and tuple collections, a deque CANNOT be sliced!
In [1]:
from collections import deque
In [3]:
q = deque()
q.appendleft(36)
q.appendleft(25)
q.appendleft(9)
q
Out[3]:
Unlike list and tuple collections, deque CANNOT be sliced!
In [5]:
q[1:]
In [ ]: