Skip to content

Heapq

Support heaps, data objects where each node is either greater than or equal to its parent (max-heap) or less than or equal to its parent (min-heap) Create a heap from {iterable}

heapq.heapify(iterable)
Remove and return the smallest element of {heap}
heapq.heappop(heap)
Replace the smallest element of {heap} with {element}
heapq.heapreplace(heap,element)