ID EN
Heapq

heappushpop

Python 3.11

Push item on the heap, then pop and return the smallest item from the heap. The combined action runs more efficiently than heappush() followed by a separate call to heappop().

Syntax

PYTHON
heapq.heappushpop(heap, item)

See Also

heappush() heappop()