Skip to content

Commit 02a6625

Browse files
committed
uasyncio.core: Introduce "trailing _" functions which avoid arg un/packing.
They just take tuple of arguments instead of *args. In most cases, that will be () singleton.
1 parent 67d8e55 commit 02a6625

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

uasyncio.core/uasyncio/core.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,19 @@ def call_soon(self, callback, *args):
2929
def call_later(self, delay, callback, *args):
3030
self.call_at(time.ticks_add(self.time(), int(delay * 1000)), callback, *args)
3131

32-
def call_later_ms(self, delay, callback, *args):
33-
self.call_at(time.ticks_add(self.time(), delay), callback, *args)
32+
def call_later_ms_(self, delay, callback, args=()):
33+
self.call_at_(time.ticks_add(self.time(), delay), callback, args)
3434

3535
def call_at(self, time, callback, *args):
3636
if __debug__:
3737
log.debug("Scheduling %s", (time, callback, args))
3838
heapq.heappush(self.q, (time, callback, args), True)
3939

40+
def call_at_(self, time, callback, args=()):
41+
if __debug__ and DEBUG:
42+
log.debug("Scheduling %s", (time, callback, args))
43+
heapq.heappush(self.q, (time, callback, args), True)
44+
4045
def wait(self, delay):
4146
# Default wait implementation, to be overriden in subclasses
4247
# with IO scheduling
@@ -106,7 +111,7 @@ def run_forever(self):
106111
if __debug__:
107112
log.debug("Coroutine finished: %s", cb)
108113
continue
109-
self.call_later_ms(delay, cb, *args)
114+
self.call_later_ms_(delay, cb, args)
110115

111116
def run_until_complete(self, coro):
112117
def _run_and_stop():

0 commit comments

Comments
 (0)