heapq

E431929

heapq is a Python standard library module that provides an implementation of the heap queue algorithm, offering efficient priority queue and heap-based operations on lists.

All labels observed (2)

How this entity was disambiguated

Statements (47)

Predicate Object
instanceOf Python standard library module
availableIn Python 2
linked to: Python 2.7

Python 3
linked to: Python 3.x
commonUseCase efficient retrieval of smallest items
merging sorted streams
priority queue implementation
top-k selection
dataStructureType binary heap
defaultHeapOrder min-heap
documentationSection Library Reference – heapq — Heap queue algorithm
linked to: heapq
heapifySignature heapify(x)
heappopSignature heappop(heap)
heapProperty parent node is less than or equal to children in min-heap
heappushSignature heappush(heap, item)
implements heap queue algorithm
importSyntax import heapq
introducedBefore Python 3.0
linked to: Python 3.x
license Python Software Foundation License
maintainedBy Python core developers
mergeSignature merge(*iterables, key=None, reverse=False)
moduleCategory Algorithms and Data Structures
mutatesInPlace True
nlargestSignature nlargest(n, iterable, key=None)
nsmallestSignature nsmallest(n, iterable, key=None)
operatesOn Python list
orderingBasis Python object comparison
partOf Python Standard Library
programmingLanguage Python
providesFunction heapify
heappop
heappush
heappushpop
heapreplace
merge
nlargest
nsmallest
requires elements to be mutually comparable
supportsCustomPriority via tuple keys
supportsIterables any iterable
supportsMaxHeap via negated priorities or custom keys
supportsMergingSortedIterables True
supportsPriorityQueueUsage True
timeComplexityHeapify O(n)
timeComplexityNlargest O(n log k)
timeComplexityNsmallest O(n log k)
timeComplexityPop O(log n)
timeComplexityPush O(log n)

How these facts were elicited

Referenced by (2)

Full triples — surface form annotated when it differs from this entity's canonical label.

heapq documentationSection Library Reference – heapq — Heap queue algorithm
linked to: heapq