Skip to content

Commit

Permalink
feat: optimize VariablePriorityQueue._get (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Dec 16, 2024
1 parent 1b51365 commit 934210e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions a_sync/primitives/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,8 +707,9 @@ def _get(self, heapify=heapq.heapify, heappop=heapq.heappop):
>>> task = queue._get()
>>> print(task)
"""
heapify(self._queue)
# take the job with the most waiters
# NOTE: Since waiter priorities can change, this might not return the job with the
# most waiters if `self._queue` is not currently in order, but after calling `heappop`,
# `self._queue` will always be in proper order for next call to `self._get`.
return heappop(self._queue)

def _get_key(self, *args, **kwargs) -> _smart._Key:
Expand Down

0 comments on commit 934210e

Please sign in to comment.