Skip to content

Commit f9eed23

Browse files
committed
uasyncio.core: Optimize for syscalls with single args.
Avoids allocating argument tuples.
1 parent 4f36827 commit f9eed23

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

uasyncio.core/uasyncio/core.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ def run_forever(self):
7171
ret = cb.send(*args)
7272
if __debug__:
7373
log.debug("Coroutine %s yield result: %s", cb, ret)
74-
if isinstance(ret, SysCall):
75-
arg = ret.args[0]
74+
if isinstance(ret, SysCall1):
75+
arg = ret.arg
7676
if isinstance(ret, Sleep):
7777
delay = arg
7878
elif isinstance(ret, IORead):
@@ -121,22 +121,28 @@ def __init__(self, *args):
121121
def handle(self):
122122
raise NotImplementedError
123123

124-
class Sleep(SysCall):
124+
# Optimized syscall with 1 arg
125+
class SysCall1(SysCall):
126+
127+
def __init__(self, arg):
128+
self.arg = arg
129+
130+
class Sleep(SysCall1):
125131
pass
126132

127-
class StopLoop(SysCall):
133+
class StopLoop(SysCall1):
128134
pass
129135

130-
class IORead(SysCall):
136+
class IORead(SysCall1):
131137
pass
132138

133-
class IOWrite(SysCall):
139+
class IOWrite(SysCall1):
134140
pass
135141

136-
class IOReadDone(SysCall):
142+
class IOReadDone(SysCall1):
137143
pass
138144

139-
class IOWriteDone(SysCall):
145+
class IOWriteDone(SysCall1):
140146
pass
141147

142148

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy