Data Structures and Algorithms
collections, heapq, bisect, array, copy, enum and itertools/functools/operator.
This is an overview — pick a sub-topic below.
Sub-topics (10)
collections
Specialised containers: Counter, defaultdict, deque, namedtuple, OrderedDict and ChainMap.
heapq
A binary min-heap on top of a list — priority queues in O(log n).
bisect
Binary search and sorted insertion on sorted lists.
array
Compact arrays of a single numeric type (much smaller than lists of ints).
copy
Shallow and deep copies of objects.
pprint
Pretty-prints nested data structures in a readable layout.
enum
Named constants grouped into a type.
itertools
Fast iterator building blocks: count, cycle, chain, product, permutations, combinations, groupby, accumulate, islice, pairwise and more.
functools
Tools for functions: lru_cache, cache, partial, reduce, wraps, singledispatch, total_ordering, cached_property.
operator
Function versions of operators (add, mul, itemgetter, attrgetter) for use with map, sorted and reduce.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.