Skip to content

Add a Heap data structure wrapping heapq functions #143

Description

@llucax

Using heapq functions on a list can be easily misused, forgetting to re-heapify the structure when manipulation is done done without using heapq functions, or using the regular pop() inadvertently.

We already have at least one instance of this causing an obscure bug in the [dispatch library](https://github.com/frequenz-floss/frequenz-dispatch-python/, which could have easily prevented if we had this kind of abstraction.

For that particular case we would need to provide a way to get an element an arbitrary index, by keeping the heap a heap. We should properly document that this could be an expensive operation though.

Coming from a post by @llucax in frequenz-floss/frequenz-dispatch-python#246 (comment)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions