10000 access self more often · python/cpython@a5b6647 · GitHub
[go: up one dir, main page]

Skip to content

Commit a5b6647

Browse files
committed
access self more often
1 parent ca5cc25 commit a5b6647

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

Lib/asyncio/base_events.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,14 +1980,12 @@ def _run_once(self):
19801980
handle._scheduled = False
19811981

19821982
timeout = None
1983-
ready = self._ready
1984-
scheduled = self._scheduled
19851983

1986-
if ready or self._stopping:
1984+
if self._ready or self._stopping:
19871985
timeout = 0
1988-
elif scheduled:
1986+
elif self._scheduled:
19891987
# Compute the desired timeout.
1990-
timeout = scheduled[0][0] - self.time()
1988+
timeout = self._scheduled[0][0] - self.time()
19911989
if timeout > MAXIMUM_SELECT_TIMEOUT:
19921990
timeout = MAXIMUM_SELECT_TIMEOUT
19931991
elif timeout < 0:
@@ -2000,21 +1998,20 @@ def _run_once(self):
20001998

20011999
# Handle 'later' callbacks that are ready.
20022000
end_time = self.time() + self._clock_resolution
2003-
while scheduled and scheduled[0][0] < end_time:
2004-
_, handle = heapq.heappop(scheduled)
2001+
while self._scheduled and self._scheduled[0][0] < end_time:
2002+
_, handle = heapq.heappop(self._scheduled)
20052003
handle._scheduled = False
2006-
ready.append(handle)
2004+
self._ready.append(handle)
20072005

20082006
# This is the only place where callbacks are actually *called*.
20092007
# All other places just add them to ready.
20102008
# Note: We run all curren 8BF5 tly scheduled callbacks, but not any
20112009
# callbacks scheduled by callbacks run this time around --
20122010
# they will be run the next time (after another I/O poll).
20132011
# Use an idiom that is thread-safe without using locks.
2014-
ntodo = len(ready)
2015-
ready_popleft = ready.popleft
2012+
ntodo = len(self._ready)
20162013
for i in range(ntodo):
2017-
handle = ready_popleft()
2014+
handle = self._ready.popleft()
20182015
if handle._cancelled:
20192016
continue
20202017
if self._debug:

0 commit comments

Comments
 (0)
0