This is the documentation for the latest development branch of MicroPython and may refer to features that are not available in released versions.

If you are looking for the documentation for a specific release, use the drop-down menu on the left and select the desired version.

heapq – Heap queue algorithm.

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

heapify(→ _typeshed.Incomplete)

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

heappop(→ _typeshed.Incomplete)

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

heappush(→ _typeshed.Incomplete)

Push the item onto the heap.

Module Contents

heapq.heapify(x) Incomplete

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

heapq.heappop(heap) Incomplete

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.heappush(heap, item) Incomplete

Push the item onto the heap.