collections

This module implements specialized container datatypes providing alternatives to Python’s general purpose built-in containers, dict, list, set, and tuple.

  • namedtuple factory function for creating tuple subclasses with named fields
  • deque list-like container with fast appends and pops on either end
  • Counter dict subclass for counting hashable objects
  • OrderedDict dict subclass that remembers the order entries were added
  • defaultdict dict subclass that calls a factory function to supply missing values

Functions

namedtuple(typename, field_names[, verbose, ...]) Returns a new subclass of tuple with named fields.

Classes

Callable
Container
Counter(*args, **kwds) Dict subclass for counting hashable items.
Hashable
ItemsView(mapping)
Iterable
Iterator
KeysView(mapping)
Mapping A Mapping is a generic container for associating key/value pairs.
MappingView(mapping)
MutableMapping A MutableMapping is a generic container for associating key/value pairs.
MutableSequence All the operations on a read-only sequence.
MutableSet A mutable set is a finite, iterable container.
OrderedDict(*args, **kwds) Dictionary that remembers insertion order
Sequence All the operations on a read-only sequence.
Set A set is a finite, iterable container.
Sized
ValuesView(mapping)
defaultdict defaultdict(default_factory[, ...]) –> dict with default factory
deque deque([iterable[, maxlen]]) –> deque object