Min-heap basics
heapq turns a plain list into a binary min-heap: smallest item at heap[0], push/pop in O(log n). Use it for top-k, k-way merge, scheduling, Dijkstra, and "running median" style problems.
Max-heap
Python 3.14 finally added public max-heap functions to heapq (heappushmax, heappopmax, ...). On older versions, or when your environment is older, use the classic trick: push negated values into a min-heap.
Tuples and tie-breaking
Heap items are compared with <, so tuples order by the first field, then the next. Push (priority, item); when items can't be compared (dicts, nodes, objects), add a unique counter as a tiebreaker. This is the shape of every Dijkstra and task-scheduler solution.
nlargest, nsmallest, merge
One-liners on top of the heap. nlargest/nsmallest return the top k items (with key=) in O(n log k); merge lazily merges already-sorted iterables, the built-in answer to "merge k sorted lists".