[Python-checkins] Update: usage doc for heappushpop (GH-91451)
rhettinger
webhook-mailer at python.org
Mon Apr 18 00:12:43 EDT 2022
https://github.com/python/cpython/commit/d7d4a0583ff8bd7c5b614490ba22e88da23b5b84
commit: d7d4a0583ff8bd7c5b614490ba22e88da23b5b84
branch: main
author: Aditya Aggarwal <aditya.aggarwal at microsoft.com>
committer: rhettinger <rhettinger at users.noreply.github.com>
date: 2022-04-17T23:12:33-05:00
summary:
Update: usage doc for heappushpop (GH-91451)
files:
M Lib/heapq.py
diff --git a/Lib/heapq.py b/Lib/heapq.py
index fabefd87f8bf8..2fd9d1ff4bf82 100644
--- a/Lib/heapq.py
+++ b/Lib/heapq.py
@@ -12,6 +12,8 @@
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
More information about the Python-checkins
mailing list