collections
The collections module contains high-performance implementations of various container data types. This is a relatively new Python module that only contains a single object as of this writing. However, it may be expanded in future releases.
deque([iterable])
Creates a double-ended queue (deque) object. iterable is an iterable object used to populate the deque. A deque allows items to be inserted or removed from either end of the queue. The implementation has been optimized so that the performance of these operations is approximately the same (O(1)). This is slightly different from a list where operations at the front of the list may require shifting of all the elements that follow.
An instance, d, of deque has the following methods: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access