diff options
-rw-r--r-- | Lib/asyncio/base_events.py | 7 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2023-10-11-18-43-43.gh-issue-110733.UlrgVm.rst | 1 |
2 files changed, 6 insertions, 2 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index b092c93..956864e 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -1907,8 +1907,11 @@ class BaseEventLoop(events.AbstractEventLoop): timeout = 0 elif self._scheduled: # Compute the desired timeout. - when = self._scheduled[0]._when - timeout = min(max(0, when - self.time()), MAXIMUM_SELECT_TIMEOUT) + timeout = self._scheduled[0]._when - self.time() + if timeout > MAXIMUM_SELECT_TIMEOUT: + timeout = MAXIMUM_SELECT_TIMEOUT + elif timeout < 0: + timeout = 0 event_list = self._selector.select(timeout) self._process_events(event_list) diff --git a/Misc/NEWS.d/next/Library/2023-10-11-18-43-43.gh-issue-110733.UlrgVm.rst b/Misc/NEWS.d/next/Library/2023-10-11-18-43-43.gh-issue-110733.UlrgVm.rst new file mode 100644 index 0000000..4963e5a --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-10-11-18-43-43.gh-issue-110733.UlrgVm.rst @@ -0,0 +1 @@ +Micro-optimization: Avoid calling ``min()``, ``max()`` in :meth:`BaseEventLoop._run_once`. |