From: Aditya Aggarwal Date: Mon, 18 Apr 2022 04:12:33 +0000 (-0500) Subject: Update: usage doc for heappushpop (GH-91451) X-Git-Tag: v3.11.0b1~323 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d7d4a0583ff8bd7c5b614490ba22e88da23b5b84;p=thirdparty%2FPython%2Fcpython.git Update: usage doc for heappushpop (GH-91451) --- diff --git a/Lib/heapq.py b/Lib/heapq.py index fabefd87f8bf..2fd9d1ff4bf8 100644 --- a/Lib/heapq.py +++ b/Lib/heapq.py @@ -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