gh-153357: Add object-oriented MinHeap and MaxHeap classes to heapq#153366
gh-153357: Add object-oriented MinHeap and MaxHeap classes to heapq#153366Twix1288 wants to merge 1 commit into
Conversation
|
This should work, let me know if any more information is needed! |
|
There are plently of unrelated changes that should be removed. I would have also waited a bit more for the OP to reply. They may have wanted to do a PR themselves. |
744410a to
ea5b53c
Compare
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
ea5b53c to
08ffd3b
Compare
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
The OP was also assigned to this, please check if someone is working on an issue before taking it on. Closing in favour of their patch. |
This PR adds the
MinHeapandMaxHeapclasses to theheapqmodule to provide an object-oriented interface over the existing heap functions.This resolves issue #153357.
Changes:
MinHeapandMaxHeaptoLib/heapq.pywith__slots__ = ('_heap',)for memory efficiency.push,pop,pushpop, andreplaceto delegate to the highly optimized underlying functions.peek(),clear(),__len__(),__bool__(),__contains__(),__iter__(), and__repr__().test_heapq.pyusing mixins to verify behavior against both pure Python (py_heapq) and C (c_heapq) underlying implementations.Doc/library/heapq.rstwith class documentation and an explicit note about__iter__and__repr__yielding raw array elements rather than fully sorted output.