On this page
heapq.heappush_max
Prev: heapq.heappush | Up: heapq | Next: heapq.heappushpop
Rel: heapq.heapify, heapq.heapify_max, heapq.heappop, heapq.heappop_max
Ref: docs.python.org — heapq.heappush_max
Tags: #public #python3 #stdlib #heapq
Import
import heapq
from heapq import heappush_max
Signature & Overview
heapq.heappush_max(heap, item, /)
Push item onto max heap, maintaining the heap invariant.
Usage
import heapq
# Python 3.14+: pushes onto a max-heap
if hasattr(heapq, "heappush_max"):
h = []
heapq.heappush_max(h, 2); heapq.heappush_max(h, 9)
assert h[0] == 9
Gotchas
- Requires Python 3.14+.
REPL Inspect
from heapq import heappush_max
help(heappush_max)
Linked from
Related notes
- tuts/python3/stdlib_module/heapq/heappush Linked here; links to this page; shared tags: #heapq, #stdlib
- tuts/python3/stdlib_module/heapq/heappushpop Linked here; links to this page; shared tags: #heapq, #stdlib
- tuts/python3/stdlib_module/heapq Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/heapq/heapify Linked here; shared tags: #heapq, #stdlib
- tuts/python3/stdlib_module/heapq/heapify_max Linked here; shared tags: #heapq, #stdlib
- tuts/python3/stdlib_module/heapq/heappop Linked here; shared tags: #heapq, #stdlib
- tuts/python3/stdlib_module/heapq/heappop_max Linked here; shared tags: #heapq, #stdlib
- tuts/python3/stdlib_module/heapq/heappushpop_max shared tags: #heapq, #stdlib
- tuts/python3/stdlib_module/heapq/heapreplace shared tags: #heapq, #stdlib
- tuts/python3/stdlib_module/heapq/heapreplace_max shared tags: #heapq, #stdlib