# `heapq` – heap queue algorithm

This module implements a subset of the corresponding CPython module, as described below. For more information, refer to the original CPython documentation: `heapq`.

This module implements the min heap queue algorithm.

A heap queue is essentially a list that has its elements stored in such a way that the first item of the list is always the smallest.

## Functions

heapq.heappush(heap, item)

  Push the `item` onto the `heap`.

heapq.heappop(heap)

  Pop the first item from the `heap`, and return it. Raise `IndexError` if `heap` is empty.

  The returned item will be the smallest item in the `heap`.

heapq.heapify(x)

  Convert the list `x` into a heap. This is an in-place operation.

Language and External Links

Language
  English
  中文

External links
  openmv.io
  forums.openmv.io
  github.com/openmv/openmv
  micropython.org
  forum.micropython.org
  github.com/micropython/micropython