zexus 1.6.8 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -5
- package/package.json +1 -1
- package/src/__init__.py +7 -0
- package/src/zexus/__init__.py +1 -1
- package/src/zexus/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/capability_system.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/debug_sanitizer.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/environment.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/error_reporter.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/input_validation.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/lexer.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/module_cache.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/module_manager.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/object.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/security.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/security_enforcement.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/syntax_validator.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/zexus_ast.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/zexus_token.cpython-312.pyc +0 -0
- package/src/zexus/access_control_system/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/access_control_system/__pycache__/access_control.cpython-312.pyc +0 -0
- package/src/zexus/advanced_types.py +17 -2
- package/src/zexus/blockchain/__init__.py +411 -0
- package/src/zexus/blockchain/accelerator.py +1160 -0
- package/src/zexus/blockchain/chain.py +660 -0
- package/src/zexus/blockchain/consensus.py +821 -0
- package/src/zexus/blockchain/contract_vm.py +1019 -0
- package/src/zexus/blockchain/crypto.py +79 -14
- package/src/zexus/blockchain/events.py +526 -0
- package/src/zexus/blockchain/loadtest.py +721 -0
- package/src/zexus/blockchain/monitoring.py +350 -0
- package/src/zexus/blockchain/mpt.py +716 -0
- package/src/zexus/blockchain/multichain.py +951 -0
- package/src/zexus/blockchain/multiprocess_executor.py +338 -0
- package/src/zexus/blockchain/network.py +886 -0
- package/src/zexus/blockchain/node.py +666 -0
- package/src/zexus/blockchain/rpc.py +1203 -0
- package/src/zexus/blockchain/rust_bridge.py +421 -0
- package/src/zexus/blockchain/storage.py +423 -0
- package/src/zexus/blockchain/tokens.py +750 -0
- package/src/zexus/blockchain/upgradeable.py +1004 -0
- package/src/zexus/blockchain/verification.py +1602 -0
- package/src/zexus/blockchain/wallet.py +621 -0
- package/src/zexus/capability_system.py +184 -9
- package/src/zexus/cli/__pycache__/main.cpython-312.pyc +0 -0
- package/src/zexus/cli/main.py +383 -34
- package/src/zexus/cli/zpm.py +1 -1
- package/src/zexus/compiler/__pycache__/bytecode.cpython-312.pyc +0 -0
- package/src/zexus/compiler/__pycache__/lexer.cpython-312.pyc +0 -0
- package/src/zexus/compiler/__pycache__/parser.cpython-312.pyc +0 -0
- package/src/zexus/compiler/__pycache__/semantic.cpython-312.pyc +0 -0
- package/src/zexus/compiler/__pycache__/zexus_ast.cpython-312.pyc +0 -0
- package/src/zexus/compiler/bytecode.py +124 -7
- package/src/zexus/compiler/compat_runtime.py +6 -2
- package/src/zexus/compiler/lexer.py +16 -5
- package/src/zexus/compiler/parser.py +108 -7
- package/src/zexus/compiler/semantic.py +18 -19
- package/src/zexus/compiler/zexus_ast.py +26 -1
- package/src/zexus/concurrency_system.py +79 -0
- package/src/zexus/config.py +54 -0
- package/src/zexus/crypto_bridge.py +244 -8
- package/src/zexus/dap/__init__.py +10 -0
- package/src/zexus/dap/__main__.py +4 -0
- package/src/zexus/dap/dap_server.py +391 -0
- package/src/zexus/dap/debug_engine.py +298 -0
- package/src/zexus/environment.py +112 -9
- package/src/zexus/evaluator/__pycache__/bytecode_compiler.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/core.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/expressions.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/functions.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/resource_limiter.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/statements.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/unified_execution.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/utils.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/bytecode_compiler.py +457 -37
- package/src/zexus/evaluator/core.py +644 -50
- package/src/zexus/evaluator/expressions.py +358 -62
- package/src/zexus/evaluator/functions.py +458 -20
- package/src/zexus/evaluator/resource_limiter.py +4 -4
- package/src/zexus/evaluator/statements.py +774 -122
- package/src/zexus/evaluator/unified_execution.py +573 -72
- package/src/zexus/evaluator/utils.py +14 -2
- package/src/zexus/evaluator_original.py +1 -1
- package/src/zexus/event_loop.py +186 -0
- package/src/zexus/lexer.py +742 -458
- package/src/zexus/lsp/__init__.py +1 -1
- package/src/zexus/lsp/definition_provider.py +163 -9
- package/src/zexus/lsp/server.py +22 -8
- package/src/zexus/lsp/symbol_provider.py +182 -9
- package/src/zexus/module_cache.py +239 -9
- package/src/zexus/module_manager.py +129 -1
- package/src/zexus/object.py +76 -6
- package/src/zexus/parser/__pycache__/parser.cpython-312.pyc +0 -0
- package/src/zexus/parser/__pycache__/strategy_context.cpython-312.pyc +0 -0
- package/src/zexus/parser/__pycache__/strategy_structural.cpython-312.pyc +0 -0
- package/src/zexus/parser/parser.py +1349 -408
- package/src/zexus/parser/strategy_context.py +755 -58
- package/src/zexus/parser/strategy_structural.py +121 -21
- package/src/zexus/persistence.py +15 -1
- package/src/zexus/renderer/__init__.py +61 -0
- package/src/zexus/renderer/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/renderer/__pycache__/backend.cpython-312.pyc +0 -0
- package/src/zexus/renderer/__pycache__/canvas.cpython-312.pyc +0 -0
- package/src/zexus/renderer/__pycache__/color_system.cpython-312.pyc +0 -0
- package/src/zexus/renderer/__pycache__/layout.cpython-312.pyc +0 -0
- package/src/zexus/renderer/__pycache__/main_renderer.cpython-312.pyc +0 -0
- package/src/zexus/renderer/__pycache__/painter.cpython-312.pyc +0 -0
- package/src/zexus/renderer/backend.py +261 -0
- package/src/zexus/renderer/canvas.py +78 -0
- package/src/zexus/renderer/color_system.py +201 -0
- package/src/zexus/renderer/graphics.py +31 -0
- package/src/zexus/renderer/layout.py +222 -0
- package/src/zexus/renderer/main_renderer.py +66 -0
- package/src/zexus/renderer/painter.py +30 -0
- package/src/zexus/renderer/tk_backend.py +208 -0
- package/src/zexus/renderer/web_backend.py +260 -0
- package/src/zexus/runtime/__init__.py +10 -2
- package/src/zexus/runtime/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/runtime/__pycache__/async_runtime.cpython-312.pyc +0 -0
- package/src/zexus/runtime/__pycache__/load_manager.cpython-312.pyc +0 -0
- package/src/zexus/runtime/file_flags.py +137 -0
- package/src/zexus/runtime/load_manager.py +368 -0
- package/src/zexus/safety/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/safety/__pycache__/memory_safety.cpython-312.pyc +0 -0
- package/src/zexus/security.py +424 -34
- package/src/zexus/stdlib/fs.py +23 -18
- package/src/zexus/stdlib/http.py +289 -186
- package/src/zexus/stdlib/sockets.py +207 -163
- package/src/zexus/stdlib/websockets.py +282 -0
- package/src/zexus/stdlib_integration.py +369 -2
- package/src/zexus/strategy_recovery.py +6 -3
- package/src/zexus/type_checker.py +423 -0
- package/src/zexus/virtual_filesystem.py +189 -2
- package/src/zexus/vm/__init__.py +113 -3
- package/src/zexus/vm/__pycache__/async_optimizer.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/bytecode.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/bytecode_converter.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/cache.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/compiler.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/gas_metering.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/jit.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/parallel_vm.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/vm.cpython-312.pyc +0 -0
- package/src/zexus/vm/async_optimizer.py +80 -6
- package/src/zexus/vm/binary_bytecode.py +659 -0
- package/src/zexus/vm/bytecode.py +59 -11
- package/src/zexus/vm/bytecode_converter.py +26 -12
- package/src/zexus/vm/cabi.c +1985 -0
- package/src/zexus/vm/cabi.cpython-312-x86_64-linux-gnu.so +0 -0
- package/src/zexus/vm/cabi.h +127 -0
- package/src/zexus/vm/cache.py +561 -17
- package/src/zexus/vm/compiler.py +818 -51
- package/src/zexus/vm/fastops.c +15743 -0
- package/src/zexus/vm/fastops.cpython-312-x86_64-linux-gnu.so +0 -0
- package/src/zexus/vm/fastops.pyx +288 -0
- package/src/zexus/vm/gas_metering.py +50 -9
- package/src/zexus/vm/jit.py +364 -20
- package/src/zexus/vm/native_jit_backend.py +1816 -0
- package/src/zexus/vm/native_runtime.cpp +1388 -0
- package/src/zexus/vm/native_runtime.cpython-312-x86_64-linux-gnu.so +0 -0
- package/src/zexus/vm/optimizer.py +161 -11
- package/src/zexus/vm/parallel_vm.py +140 -45
- package/src/zexus/vm/peephole_optimizer.py +82 -4
- package/src/zexus/vm/profiler.py +38 -18
- package/src/zexus/vm/register_allocator.py +16 -5
- package/src/zexus/vm/register_vm.py +8 -5
- package/src/zexus/vm/vm.py +3581 -531
- package/src/zexus/vm/wasm_compiler.py +658 -0
- package/src/zexus/zexus_ast.py +137 -11
- package/src/zexus/zexus_token.py +16 -5
- package/src/zexus/zpm/installer.py +55 -15
- package/src/zexus/zpm/package_manager.py +1 -1
- package/src/zexus/zpm/registry.py +257 -28
- package/src/zexus.egg-info/PKG-INFO +16 -6
- package/src/zexus.egg-info/SOURCES.txt +129 -17
- package/src/zexus.egg-info/entry_points.txt +1 -0
- package/src/zexus.egg-info/requires.txt +4 -0
package/src/zexus/vm/__init__.py
CHANGED
|
@@ -1,8 +1,118 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Zexus Virtual Machine - Backend Execution Engine
|
|
3
|
+
|
|
4
|
+
This package provides a comprehensive VM system for Zexus with:
|
|
5
|
+
- Stack-based VM (standard execution)
|
|
6
|
+
- Register-based VM (optimized paths)
|
|
7
|
+
- Parallel VM (multi-core execution)
|
|
8
|
+
- JIT compilation (hot path native code)
|
|
9
|
+
- Peephole optimizer (bytecode optimization)
|
|
10
|
+
- Bytecode caching (persistent across runs)
|
|
11
|
+
- Memory pooling (efficient allocation)
|
|
12
|
+
- Gas metering (resource control)
|
|
3
13
|
"""
|
|
4
14
|
|
|
5
|
-
|
|
6
|
-
from .
|
|
15
|
+
# Core VM
|
|
16
|
+
from .vm import VM as ZexusVM, VMMode
|
|
17
|
+
from .bytecode import Bytecode, Opcode, BytecodeBuilder
|
|
18
|
+
|
|
19
|
+
# Caching system (with file-based persistence)
|
|
20
|
+
from .cache import BytecodeCache, CacheStats, FileMetadata
|
|
21
|
+
|
|
22
|
+
# Compilers
|
|
23
|
+
from .compiler import BytecodeCompiler
|
|
24
|
+
|
|
25
|
+
# Optimizers
|
|
26
|
+
try:
|
|
27
|
+
from .optimizer import BytecodeOptimizer
|
|
28
|
+
OPTIMIZER_AVAILABLE = True
|
|
29
|
+
except ImportError:
|
|
30
|
+
BytecodeOptimizer = None
|
|
31
|
+
OPTIMIZER_AVAILABLE = False
|
|
32
|
+
|
|
33
|
+
try:
|
|
34
|
+
from .peephole_optimizer import PeepholeOptimizer, OptimizationLevel
|
|
35
|
+
PEEPHOLE_AVAILABLE = True
|
|
36
|
+
except ImportError:
|
|
37
|
+
PeepholeOptimizer = None
|
|
38
|
+
OptimizationLevel = None
|
|
39
|
+
PEEPHOLE_AVAILABLE = False
|
|
40
|
+
|
|
41
|
+
# JIT
|
|
42
|
+
try:
|
|
43
|
+
from .jit import JITCompiler, ExecutionTier
|
|
44
|
+
JIT_AVAILABLE = True
|
|
45
|
+
except ImportError:
|
|
46
|
+
JITCompiler = None
|
|
47
|
+
ExecutionTier = None
|
|
48
|
+
JIT_AVAILABLE = False
|
|
49
|
+
|
|
50
|
+
# Register VM
|
|
51
|
+
try:
|
|
52
|
+
from .register_vm import RegisterVM
|
|
53
|
+
REGISTER_VM_AVAILABLE = True
|
|
54
|
+
except ImportError:
|
|
55
|
+
RegisterVM = None
|
|
56
|
+
REGISTER_VM_AVAILABLE = False
|
|
57
|
+
|
|
58
|
+
# Parallel VM
|
|
59
|
+
try:
|
|
60
|
+
from .parallel_vm import ParallelVM, ExecutionMode
|
|
61
|
+
PARALLEL_VM_AVAILABLE = True
|
|
62
|
+
except ImportError:
|
|
63
|
+
ParallelVM = None
|
|
64
|
+
ExecutionMode = None
|
|
65
|
+
PARALLEL_VM_AVAILABLE = False
|
|
66
|
+
|
|
67
|
+
# Memory management
|
|
68
|
+
try:
|
|
69
|
+
from .memory_pool import IntegerPool, StringPool, ListPool
|
|
70
|
+
MEMORY_POOL_AVAILABLE = True
|
|
71
|
+
except ImportError:
|
|
72
|
+
IntegerPool = None
|
|
73
|
+
StringPool = None
|
|
74
|
+
ListPool = None
|
|
75
|
+
MEMORY_POOL_AVAILABLE = False
|
|
76
|
+
|
|
77
|
+
# Gas metering
|
|
78
|
+
try:
|
|
79
|
+
from .gas_metering import GasMetering, OutOfGasError
|
|
80
|
+
GAS_METERING_AVAILABLE = True
|
|
81
|
+
except ImportError:
|
|
82
|
+
GasMetering = None
|
|
83
|
+
OutOfGasError = None
|
|
84
|
+
GAS_METERING_AVAILABLE = False
|
|
85
|
+
|
|
86
|
+
# Profiler
|
|
87
|
+
try:
|
|
88
|
+
from .profiler import InstructionProfiler, ProfilingLevel
|
|
89
|
+
PROFILER_AVAILABLE = True
|
|
90
|
+
except ImportError:
|
|
91
|
+
InstructionProfiler = None
|
|
92
|
+
ProfilingLevel = None
|
|
93
|
+
PROFILER_AVAILABLE = False
|
|
7
94
|
|
|
8
|
-
__all__ = [
|
|
95
|
+
__all__ = [
|
|
96
|
+
# Core
|
|
97
|
+
'ZexusVM', 'VMMode', 'Bytecode', 'Opcode', 'BytecodeBuilder',
|
|
98
|
+
# Cache
|
|
99
|
+
'BytecodeCache', 'CacheStats', 'FileMetadata',
|
|
100
|
+
# Compiler
|
|
101
|
+
'BytecodeCompiler',
|
|
102
|
+
# Optimizers
|
|
103
|
+
'BytecodeOptimizer', 'PeepholeOptimizer', 'OptimizationLevel',
|
|
104
|
+
# JIT
|
|
105
|
+
'JITCompiler', 'ExecutionTier',
|
|
106
|
+
# Advanced VMs
|
|
107
|
+
'RegisterVM', 'ParallelVM', 'ExecutionMode',
|
|
108
|
+
# Memory
|
|
109
|
+
'IntegerPool', 'StringPool', 'ListPool',
|
|
110
|
+
# Gas
|
|
111
|
+
'GasMetering', 'OutOfGasError',
|
|
112
|
+
# Profiler
|
|
113
|
+
'InstructionProfiler', 'ProfilingLevel',
|
|
114
|
+
# Availability flags
|
|
115
|
+
'OPTIMIZER_AVAILABLE', 'PEEPHOLE_AVAILABLE', 'JIT_AVAILABLE',
|
|
116
|
+
'REGISTER_VM_AVAILABLE', 'PARALLEL_VM_AVAILABLE',
|
|
117
|
+
'MEMORY_POOL_AVAILABLE', 'GAS_METERING_AVAILABLE', 'PROFILER_AVAILABLE',
|
|
118
|
+
]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -97,7 +97,7 @@ class FastFuture:
|
|
|
97
97
|
"""Make it awaitable - fast path, no event loop"""
|
|
98
98
|
if self._exception:
|
|
99
99
|
raise self._exception
|
|
100
|
-
yield from
|
|
100
|
+
yield from ()
|
|
101
101
|
return self._value
|
|
102
102
|
|
|
103
103
|
|
|
@@ -143,6 +143,10 @@ class CoroutinePool:
|
|
|
143
143
|
Args:
|
|
144
144
|
wrapper: Wrapper to release
|
|
145
145
|
"""
|
|
146
|
+
# Make sure underlying coroutine isn't left pending
|
|
147
|
+
if hasattr(wrapper, "_dispose_coroutine"):
|
|
148
|
+
wrapper._dispose_coroutine()
|
|
149
|
+
|
|
146
150
|
if len(self.pool) < self.max_size:
|
|
147
151
|
self.pool.append(wrapper)
|
|
148
152
|
|
|
@@ -169,15 +173,72 @@ class PooledCoroutineWrapper:
|
|
|
169
173
|
return self._coro.send(value)
|
|
170
174
|
|
|
171
175
|
def throw(self, typ, val=None, tb=None):
|
|
172
|
-
"""Forward throw"""
|
|
173
|
-
|
|
176
|
+
"""Forward throw while supporting modern coroutine semantics."""
|
|
177
|
+
coro_throw = getattr(self._coro, "throw", None)
|
|
178
|
+
if coro_throw is None:
|
|
179
|
+
raise AttributeError("Wrapped coroutine does not support throw()")
|
|
180
|
+
|
|
181
|
+
# Normalize exception according to modern coroutine API expectations
|
|
182
|
+
if tb is None and val is None:
|
|
183
|
+
return coro_throw(typ)
|
|
184
|
+
|
|
185
|
+
if tb is None and isinstance(typ, BaseException) and val is None:
|
|
186
|
+
return coro_throw(typ)
|
|
187
|
+
|
|
188
|
+
if isinstance(typ, BaseException):
|
|
189
|
+
exc = typ
|
|
190
|
+
if val is not None and val is not exc:
|
|
191
|
+
exc.args = exc.args or ()
|
|
192
|
+
exc.args += (val,)
|
|
193
|
+
elif isinstance(typ, type) and issubclass(typ, BaseException):
|
|
194
|
+
if isinstance(val, typ):
|
|
195
|
+
exc = val
|
|
196
|
+
elif val is None:
|
|
197
|
+
exc = typ()
|
|
198
|
+
else:
|
|
199
|
+
exc = typ(val)
|
|
200
|
+
else:
|
|
201
|
+
# Fall back to legacy behaviour for non-exception inputs
|
|
202
|
+
if tb is not None:
|
|
203
|
+
return coro_throw(typ, val, tb)
|
|
204
|
+
if val is not None:
|
|
205
|
+
return coro_throw(typ, val)
|
|
206
|
+
return coro_throw(typ)
|
|
207
|
+
|
|
208
|
+
if tb is not None and hasattr(exc, "with_traceback"):
|
|
209
|
+
exc = exc.with_traceback(tb)
|
|
210
|
+
|
|
211
|
+
return coro_throw(exc)
|
|
174
212
|
|
|
175
213
|
def close(self):
|
|
176
214
|
"""Close and return to pool"""
|
|
215
|
+
self._dispose_coroutine()
|
|
216
|
+
self._pool.release_wrapper(self)
|
|
217
|
+
|
|
218
|
+
# Internal helpers -------------------------------------------------
|
|
219
|
+
|
|
220
|
+
def _dispose_coroutine(self):
|
|
221
|
+
coro = getattr(self, "_coro", None)
|
|
222
|
+
if coro is None:
|
|
223
|
+
return
|
|
224
|
+
|
|
177
225
|
try:
|
|
178
|
-
|
|
226
|
+
close = getattr(coro, "close", None)
|
|
227
|
+
if callable(close):
|
|
228
|
+
try:
|
|
229
|
+
close()
|
|
230
|
+
except RuntimeError:
|
|
231
|
+
# Coroutine already completed or running elsewhere
|
|
232
|
+
pass
|
|
179
233
|
finally:
|
|
180
|
-
self.
|
|
234
|
+
self._coro = None
|
|
235
|
+
|
|
236
|
+
def __del__(self):
|
|
237
|
+
try:
|
|
238
|
+
self._dispose_coroutine()
|
|
239
|
+
except Exception:
|
|
240
|
+
# Destructors must never raise
|
|
241
|
+
pass
|
|
181
242
|
|
|
182
243
|
|
|
183
244
|
class BatchAwaitDetector:
|
|
@@ -267,9 +328,18 @@ class AsyncOptimizer:
|
|
|
267
328
|
|
|
268
329
|
# Use pooling if enabled
|
|
269
330
|
if self.coroutine_pool and self.level.value >= AsyncOptimizationLevel.BASIC.value:
|
|
270
|
-
|
|
331
|
+
wrapper = self.coroutine_pool.get_wrapper(coro)
|
|
332
|
+
return self._wrap_pooled(wrapper)
|
|
271
333
|
|
|
272
334
|
return coro
|
|
335
|
+
|
|
336
|
+
async def _wrap_pooled(self, wrapper: PooledCoroutineWrapper) -> Any:
|
|
337
|
+
"""Ensure pooled wrappers are released after completion."""
|
|
338
|
+
try:
|
|
339
|
+
return await wrapper
|
|
340
|
+
finally:
|
|
341
|
+
if self.coroutine_pool:
|
|
342
|
+
self.coroutine_pool.release_wrapper(wrapper)
|
|
273
343
|
|
|
274
344
|
async def await_optimized(self, awaitable: Any) -> Any:
|
|
275
345
|
"""
|
|
@@ -285,6 +355,10 @@ class AsyncOptimizer:
|
|
|
285
355
|
|
|
286
356
|
# Fast path for already-resolved futures (MODERATE+)
|
|
287
357
|
if self.level.value >= AsyncOptimizationLevel.MODERATE.value:
|
|
358
|
+
if not asyncio.isfuture(awaitable) and not asyncio.iscoroutine(awaitable) and not hasattr(awaitable, "__await__"):
|
|
359
|
+
self.stats.fast_path_hits += 1
|
|
360
|
+
self.stats.event_loop_skips += 1
|
|
361
|
+
return awaitable
|
|
288
362
|
if isinstance(awaitable, FastFuture):
|
|
289
363
|
self.stats.fast_path_hits += 1
|
|
290
364
|
self.stats.event_loop_skips += 1
|