Skip to content

GH-112498 Add heapremove and heapfix - #112550

Closed
kristjanvalur wants to merge 15 commits into
python:mainfrom
kristjanvalur:kristjan/heapremove2
Closed

kristjanvalur wants to merge 15 commits into
python:mainfrom
kristjanvalur:kristjan/heapremove2

Conversation

@kristjanvalur

@kristjanvalur kristjanvalur commented Nov 30, 2023 •

Copy link
Copy Markdown
Contributor

This is an alternative PR to #112497 which adds two functions, heapfix and heapremove.
This is perhaps better, since the use cases are different. heappop becomes a special case of heapremove and

It corresponds to what golang does in https://pkg.go.dev/container/heap


📚 Documentation preview 📚: https://cpython-previews--112550.org.readthedocs.build/

@StanFromIreland StanFromIreland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think max heaps should have an equivalent API to avoid confusion.

Comment thread Doc/library/heapq.rst

Raises :exc:`ValueError` if no item corresponding to *value* is found.

.. versionadded:: 3.13

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change these to next

Comment thread Doc/library/heapq.rst

The heap is searched for the first item comparing equal to *value*.

If the _callable_ *key* is provided, it will be called for each item

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is restructured text, underscores will not work.

@kristjanvalur

Copy link
Copy Markdown
Contributor Author

this PR is two years old, not sure there is any interest in pursuing it. It was at best lukewarm at the time.

@rhettinger rhettinger closed this Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants