On this page
heapq.heappop_max
Prev: heapq.heappop | Up: heapq | Next: heapq.heappush
Rel: heapq.heapify, heapq.heapify_max, heapq.heappop, heapq.heappush
Ref: docs.python.org — heapq.heappop_max
Tags: #public #python3 #stdlib #heapq
Import
import heapq
from heapq import heappop_max
Signature & Overview
heapq.heappop_max(heap, /)
Maxheap variant of heappop.
Usage
import heapq
# Python 3.14+: pops largest element from a max-heap
if hasattr(heapq, "heappop_max"):
h = [1, 5, 3]
heapq.heapify_max(h)
assert heapq.heappop_max(h) == 5
Gotchas
- Requires Python 3.14+: Only use on lists maintained with
heapify_max/heappush_max.
REPL Inspect
from heapq import heappop_max
help(heappop_max)
Linked from
- tuts/python3/stdlib_module/heapq
- tuts/python3/stdlib_module/heapq/heapify
- tuts/python3/stdlib_module/heapq/heapify_max
- tuts/python3/stdlib_module/heapq/heappop
- tuts/python3/stdlib_module/heapq/heappush
- tuts/python3/stdlib_module/heapq/heappush_max
- tuts/python3/stdlib_module/heapq/heappushpop
- tuts/python3/stdlib_module/heapq/heappushpop_max
- tuts/python3/stdlib_module/heapq/heapreplace
- tuts/python3/stdlib_module/heapq/heapreplace_max
- tuts/python3/stdlib_module/heapq/merge
- tuts/python3/stdlib_module/heapq/nlargest
- tuts/python3/stdlib_module/heapq/nsmallest
Related notes
- tuts/python3/stdlib_module/heapq/heapify Linked here; links to this page; shared tags: #heapq, #stdlib
- tuts/python3/stdlib_module/heapq/heapify_max Linked here; links to this page; shared tags: #heapq, #stdlib
- tuts/python3/stdlib_module/heapq/heappop Linked here; links to this page; shared tags: #heapq, #stdlib
- tuts/python3/stdlib_module/heapq/heappush 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/heappush_max links to this page; shared tags: #heapq, #stdlib
- tuts/python3/stdlib_module/heapq/heappushpop links to this page; shared tags: #heapq, #stdlib
- tuts/python3/stdlib_module/heapq/heappushpop_max links to this page; shared tags: #heapq, #stdlib
- tuts/python3/stdlib_module/heapq/heapreplace links to this page; shared tags: #heapq, #stdlib
- tuts/python3/stdlib_module/heapq/heapreplace_max links to this page; shared tags: #heapq, #stdlib