Skip to content

Commit 5d2d387

Browse files
Benedikts Suggestions
1 parent 3cde6c6 commit 5d2d387

File tree

4 files changed

+40
-13
lines changed

4 files changed

+40
-13
lines changed

Doc/library/heapq.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ The following functions are provided:
8484
on the heap.
8585

8686

87-
For max-heaps, the reverse of a heap, the following functions are provided:
87+
For max-heaps, the following functions are provided:
8888

8989

9090
.. function:: heapify_max(x)
@@ -103,7 +103,7 @@ For max-heaps, the reverse of a heap, the following functions are provided:
103103

104104
.. function:: heappop_max(heap)
105105

106-
Pop and return the largest item from the max-*heap*, maintaining the heap
106+
Pop and return the largest item from the max-heap *heap*, maintaining the heap
107107
invariant. If the max-heap is empty, :exc:`IndexError` is raised. To access the
108108
largest item without popping it, use ``heap[0]``.
109109

@@ -112,7 +112,7 @@ For max-heaps, the reverse of a heap, the following functions are provided:
112112

113113
.. function:: heappushpop_max(heap, item)
114114

115-
Push *item* on the max-heap, then pop and return the largest item from *heap*.
115+
Push *item* on the max-heap *heap*, then pop and return the largest item from *heap*.
116116
The combined action runs more efficiently than :func:`heappush_max`
117117
followed by a separate call to :func:`heappop_max`.
118118

Doc/whatsnew/3.14.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,23 @@ getopt
563563
* Add support for returning intermixed options and non-option arguments in order.
564564
(Contributed by Serhiy Storchaka in :gh:`126390`.)
565565

566+
567+
heapq
568+
-----
569+
570+
* Make :mod:`heapq` max-heap functions
571+
572+
* :func:`heapify_max`,
573+
* :func:`heappush_max`,
574+
* :func:`heappop_max`,
575+
* :func:`heapreplace_max`
576+
577+
public. And add the missing :func:`heappushpop_max` to
578+
both the C and Python implementation.
579+
580+
Previous underscored naming is kept for backwards compatibility.
581+
582+
566583
http
567584
----
568585

Lib/test/test_heapq.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,11 @@ def test_push_pop(self):
6969

7070
self.assertRaises(TypeError, self.module.heappush, [])
7171

72-
exc_types = (AttributeError, TypeError)
73-
self.assertRaises(exc_types, self.module.heappush, None, None)
74-
self.assertRaises(exc_types, self.module.heappop, None)
75-
72+
try:
73+
self.assertRaises(TypeError, self.module.heappush, None, None)
74+
self.assertRaises(TypeError, self.module.heappop, None)
75+
except AttributeError:
76+
pass
7677

7778
def test_max_push_pop(self):
7879
# 1) Push 256 random numbers and pop them off, verifying all's OK.
@@ -97,11 +98,10 @@ def test_max_push_pop(self):
9798
self.check_max_invariant(results)
9899

99100
self.assertRaises(TypeError, self.module.heappush_max, [])
100-
try:
101-
self.assertRaises(TypeError, self.module.heappush_max, None, None)
102-
self.assertRaises(TypeError, self.module.heappop_max, None)
103-
except AttributeError:
104-
pass
101+
102+
exc_types = (AttributeError, TypeError)
103+
self.assertRaises(exc_types, self.module.heappush_max, None, None)
104+
self.assertRaises(exc_types, self.module.heappop_max, None)
105105

106106
def check_invariant(self, heap):
107107
# Check the heap invariant.
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
Make max heap functions public.
1+
Make :mod:`heapq` max-heap functions
2+
3+
* :func:`heapify_max`,
4+
* :func:`heappush_max`,
5+
* :func:`heappop_max`,
6+
* :func:`heapreplace_max`
7+
8+
public. And add the missing :func:`heappushpop_max` to
9+
both the C and Python implementation.
10+
11+
Previous underscored naming is kept for backwards compatibility.

0 commit comments

Comments
 (0)