heapq
Also written: heapq.nlargest, heapq.nsmallest, nlargest, nsmallest, heap
Python's heap module. `nlargest` and `nsmallest` return the top k items by a `key`, in O(n log k).
Also written: heapq.nlargest, heapq.nsmallest, nlargest, nsmallest, heap
Python's heap module. `nlargest` and `nsmallest` return the top k items by a `key`, in O(n log k).