Skip to content

Maxheap version of a heappush #110067

Closed
Closed

Description

@coopers

Feature or enhancement

Proposal:

def _heappush_max(heap, item):
    """Maxheap version of a heappush."""
    heap.append(item)
    _siftdown_max(heap, 0, len(heap)-1)

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

conversation on making max heap functions public

Linked PRs

Activity

  1. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Nov 27, 2023
  2. encukou commented on Mar 4, 2024

    @encukou
    Member

    Functions with a leading underscore are private -- i.e. _heappush_max should not be used outside heapq itself. It should be named without an underscore, and it would also need documentation and tests.

    Raymond said he's working on public maxheap functions. If you'd like to work on this, perhaps ask if he's still on it.

  3. rhettinger commented on Mar 13, 2024

    @rhettinger
    Contributor

    Yes, I've still got this.

  4. tnightengale commented on Nov 24, 2024

    @tnightengale

    @rhettinger 👋 Would you like any help on this? Recently I reached for a max-heap in python and was surprised it didn't exist. Saw this thread and wondered if this is still on anyone's radar, since it was not released with 3.13.

  5. Teut2711 commented on Dec 13, 2024

    @Teut2711

    Anyone still working on it ?

  6. added a commit that references this issue on Feb 17, 2025
  7. added a commit that references this issue on May 5, 2025
  8. StanFromIreland commented on May 6, 2025

    @StanFromIreland
    Member

    This can be closed now. I will add some further documentation updates in a follow up.

  9. encukou commented on May 7, 2025

    @encukou
    Member

    You could reuse this issue.

  10. StanFromIreland commented on May 7, 2025

    @StanFromIreland
    Member

    I had already created #133530, apologies, it just seemed a bit messy to use this one since there is a lot of unrelated comments.

  11. encukou commented on May 8, 2025

    @encukou
    Member

    That works too, especially if the changes aren't all related to max-heaps. (But, I wouldn't close before adding the link to the follow-up.)

    @rhettinger: Please feel free to reopen if you want (us) to rework or remove the feature. There's time for than until July 28.

  12. added a commit that references this issue on Jul 12, 2025
  13. added 5 commits that reference this issue on Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

extension-modulesC modules in the Modules dirstdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions