Skip to content
11 changes: 7 additions & 4 deletions Doc/library/collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,8 @@ or subtracting from an empty counter.
corresponding number of items are discarded from the opposite end. Bounded
length deques provide functionality similar to the ``tail`` filter in
Unix. They are also useful for tracking transactions and other pools of data
where only the most recent activity is of interest.
where only the most recent activity is of interest. Passing a *maxlen*
greater than :data:`sys.maxsize` raises :exc:`ValueError`.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also leave the behaviour the same as before (raise OverflowError), or fix it to be in line with what eg slicing for lists does (which handles huge numbers gracefully.)



Deque objects support the following methods:
Expand Down Expand Up @@ -591,9 +592,11 @@ or subtracting from an empty counter.

In addition to the above, deques support iteration, pickling, ``len(d)``,
``reversed(d)``, ``copy.copy(d)``, ``copy.deepcopy(d)``, membership testing with
the :keyword:`in` operator, and subscript references such as ``d[0]`` to access
the first element. Indexed access is *O*\ (1) at both ends but slows to *O*\ (*n*) in
the middle. For fast random access, use lists instead.
the :keyword:`in` operator, subscript references such as ``d[0]`` to access
the first element, and slicing notation like ``d[i:j:k]`` which returns a new
deque of the same type (including subclasses) while preserving ``maxlen``.
Indexed access is *O*\ (1). Slicing is *O*\ (k) where *k* is the number of
elements in the slice.

Starting in version 3.5, deques support ``__add__()``, ``__mul__()``,
and ``__imul__()``.
Expand Down
6 changes: 6 additions & 0 deletions Lib/collections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
except ImportError:
pass

try:
# Ditto for reverse iterators (used by pickle reducers)
from _collections import _deque_reverse_iterator # noqa: F401
except ImportError:
pass

try:
from _collections import defaultdict
except ImportError:
Expand Down
Loading
Loading