Visitar URL original
Weird PriorityQueue description · Issue #101777 · python/cpython · GitHub
Skip to content

Weird PriorityQueue description #101777

Description

@pochmann

Documentation

Someone asked Does PriorityQueue call sorted every time get is called?. First I laughed, how did they come up with that silly idea, but then I saw they got it from the doc and it really does make it sound like that:

The lowest valued entries are retrieved first (the lowest valued entry is the one returned by sorted(list(entries))[0]).

Not only sorted but also list first, and of course even if the queue didn't use a heap, it should be the straightforward min(entries) instead. This is so over-the-top inefficient and complicated that it looks like a weird joke.

Unless there's good reason for it, I suggest to add "as if" and use min:

The lowest valued entries are retrieved first (the lowest valued entry is the one as if returned by min(entries)).

Linked PRs

Activity

  1. ericvsmith commented on Feb 10, 2023

    @ericvsmith
    Member

    I'm not sure it needs to be changed, but if it must be, then I'd say something like "the one that would be returned by ...".

  2. pochmann commented on Feb 10, 2023

    @pochmann
    ContributorAuthor

    Yes, that's better.

  3. rhettinger commented on Feb 15, 2023

    @rhettinger
    Contributor

    +1

  4. added a commit that references this issue on Feb 21, 2023
  5. added 4 commits that reference this issue on Feb 21, 2023
  6. added a commit that references this issue on Feb 22, 2023
  7. added 4 commits that reference this issue on Feb 22, 2023
  8. added a commit that references this issue on Feb 23, 2023
  9. added 2 commits that reference this issue on Sep 1, 2024
  10. added 2 commits that reference this issue on Sep 10, 2024
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

    docsDocumentation in the Doc dir

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions