summaryrefslogtreecommitdiffstats
path: root/Lib/heapq.py
diff options
context:
space:
mode:
authorAditya Aggarwal <aditya.aggarwal@microsoft.com>2022-04-18 04:12:33 (GMT)
committerGitHub <noreply@github.com>2022-04-18 04:12:33 (GMT)
commitd7d4a0583ff8bd7c5b614490ba22e88da23b5b84 (patch)
treef0ce11f43a3a73b2c47db5cd955dc40ba77cbfb7 /Lib/heapq.py
parenta573cb2fec664c645ab744658d7e941d72e1a398 (diff)
downloadcpython-d7d4a0583ff8bd7c5b614490ba22e88da23b5b84.zip
cpython-d7d4a0583ff8bd7c5b614490ba22e88da23b5b84.tar.gz
cpython-d7d4a0583ff8bd7c5b614490ba22e88da23b5b84.tar.bz2
Update: usage doc for heappushpop (GH-91451)
Diffstat (limited to 'Lib/heapq.py')
-rw-r--r--Lib/heapq.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/heapq.py b/Lib/heapq.py
index fabefd8..2fd9d1f 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