mirror of
https://github.com/python/cpython.git
synced 2024-11-23 18:04:37 +08:00
gh-106751: Optimize SelectSelector.select() for many iteration case (gh-106879)
This commit is contained in:
parent
7513e2e7e4
commit
e6f96cf9c6
@ -314,17 +314,15 @@ class SelectSelector(_BaseSelectorImpl):
|
|||||||
r, w, _ = self._select(self._readers, self._writers, [], timeout)
|
r, w, _ = self._select(self._readers, self._writers, [], timeout)
|
||||||
except InterruptedError:
|
except InterruptedError:
|
||||||
return ready
|
return ready
|
||||||
r = set(r)
|
r = frozenset(r)
|
||||||
w = set(w)
|
w = frozenset(w)
|
||||||
for fd in r | w:
|
rw = r | w
|
||||||
events = 0
|
fd_to_key_get = self._fd_to_key.get
|
||||||
if fd in r:
|
for fd in rw:
|
||||||
events |= EVENT_READ
|
key = fd_to_key_get(fd)
|
||||||
if fd in w:
|
|
||||||
events |= EVENT_WRITE
|
|
||||||
|
|
||||||
key = self._fd_to_key.get(fd)
|
|
||||||
if key:
|
if key:
|
||||||
|
events = ((fd in r and EVENT_READ)
|
||||||
|
| (fd in w and EVENT_WRITE))
|
||||||
ready.append((key, events & key.events))
|
ready.append((key, events & key.events))
|
||||||
return ready
|
return ready
|
||||||
|
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
Optimize :meth:`SelectSelector.select` for many iteration case. Patch By
|
||||||
|
Dong-hee Na.
|
Loading…
Reference in New Issue
Block a user