On this page
  1. heapq.heappop_max
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

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

REPL Inspect

from heapq import heappop_max
help(heappop_max)

Linked from

Related notes