O'Reilly logo

Python: Essential Reference, Third Edition by David Beazley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required