{
  "id": "python-heapq-table",
  "kind": "table",
  "slug": "python-heapq",
  "iil_id": null,
  "note_url": "https://iinventedlight.com/library/notes/python-heapq/",
  "title": "Python heapq keeps a list as a min-heap for priority queues and n-smallest queries",
  "columns": [
    "name",
    "source",
    "detail"
  ],
  "rows": [
    {
      "name": "heappop",
      "source": "Python docs",
      "detail": "raises IndexError if the heap is empty; use heap[0] to see the smallest item without popping it."
    },
    {
      "name": "heappushpop(heap, item)",
      "source": "Python docs",
      "detail": "pushes then pops, which runs more efficiently than separate calls; it returns the smaller of the two values."
    },
    {
      "name": "nlargest(n, iterable, key=None)",
      "source": "Python docs",
      "detail": "is equivalent to sorted(iterable, key=key, reverse=True)[:n], and nsmallest to sorted(iterable, key=key)[:n]."
    }
  ],
  "related_slugs": [
    "python-bisect",
    "python-collections-containers",
    "python-itertools"
  ],
  "license": "CC-BY-4.0",
  "source_license": "PSF-2.0 (Python docs); PSF-2.0 (python/cpython (GitHub)); prose restates cited source lines in own words",
  "as_of": "2026-11-18",
  "status": "fill-draft-20261118",
  "note": "Restated from the note's GREEN sources; check those sources before relying on a value."
}