]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Update: usage doc for heappushpop (GH-91451)
authorAditya Aggarwal <aditya.aggarwal@microsoft.com>
Mon, 18 Apr 2022 04:12:33 +0000 (23:12 -0500)
committerGitHub <noreply@github.com>
Mon, 18 Apr 2022 04:12:33 +0000 (23:12 -0500)
Lib/heapq.py

index fabefd87f8bf8c804e8eb3155c1aacbf05dd02bd..2fd9d1ff4bf827b4c919253be98a7ee0c3f7b829 100644 (file)
@@ -12,6 +12,8 @@ heappush(heap, item) # pushes a new item on the heap
 item = heappop(heap) # pops the smallest item from the heap
 item = heap[0]       # smallest item on the heap without popping it
 heapify(x)           # transforms list into a heap, in-place, in linear time
+item = heappushpop(heap, item) # pushes a new item and then returns
+                               # the smallest item; the heap size is unchanged
 item = heapreplace(heap, item) # pops and returns smallest item, and adds
                                # new item; the heap size is unchanged