On this page
heapq.heapify_max
Prev: heapq.heapify | Up: heapq | Next: heapq.heappop
Rel: heapq.heapify, heapq.heappop, heapq.heappop_max, heapq.heappush
Ref: docs.python.org — heapq.heapify_max
Tags: #public #python3 #stdlib #heapq
Import
import heapq
from heapq import heapify_max
Signature & Overview
heapq.heapify_max(heap, /)
Maxheap variant of heapify.
Usage
import heapq
# Python 3.14+: in-place max-heap construction
if hasattr(heapq, "heapify_max"):
nums = [1, 5, 3]
heapq.heapify_max(nums)
assert nums[0] == 5
Gotchas
- Requires Python 3.14+: On older Python, negate numeric keys (
-x) in a standard min-heap.
REPL Inspect
from heapq import heapify_max
help(heapify_max)
Linked from
- tuts/python3/stdlib_module/heapq
- tuts/python3/stdlib_module/heapq/heapify
- tuts/python3/stdlib_module/heapq/heappop
- tuts/python3/stdlib_module/heapq/heappop_max
- 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/heappop Linked here; links to this page; shared tags: #heapq, #stdlib
- tuts/python3/stdlib_module/heapq/heappop_max 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