Skip to content

Speed up Condition.notify() #92352

@dgiger42

Description

@dgiger42

Feature or enhancement

I think threading.Condition.notify() could be sped up by avoiding some unnecessary work. Condition.notify() creates a _deque every time it is called, and it seems like this step can be eliminated. This should speed up notify() without sacrificing readability. The for loop at the end of the function would most likely need to be slightly tweaked to accommodate this change.

Pitch

This change should speed up Condition.notify(), which would also speed up operations on queue.Queue, since the Queue class uses Condition objects extensively. The speedup for Queue could be significant, because Queue appears to spend a significant portion of it's time in notify() (or at least it did when I profiled a simple program that was using Queue).

If I'm right that this can be sped up significantly without sacrificing readability, should I make a PR for it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance or resource usagetype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions