Skip to content

Commit

Permalink
pythongh-106751: Optimize SelectSelector.select() for many iteration …
Browse files Browse the repository at this point in the history
…case
  • Loading branch information
corona10 committed Jul 19, 2023
1 parent 7513e2e commit 8edbde4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 6 additions & 8 deletions Lib/selectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,13 @@ def select(self, timeout=None):
return ready
r = set(r)
w = set(w)
for fd in r | w:
events = 0
if fd in r:
events |= EVENT_READ
if fd in w:
events |= EVENT_WRITE

key = self._fd_to_key.get(fd)
rw = r | w
fd_to_key_get = self._fd_to_key.get
for fd in rw:
key = fd_to_key_get(fd)
if key:
events = ((fd in r and EVENT_READ)
| (fd in w and EVENT_WRITE))
ready.append((key, events & key.events))
return ready

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Optimize :meth:`SelectSelector.select` for many iteration case. Patch By
Dong-hee Na.

0 comments on commit 8edbde4

Please sign in to comment.