Runtime
PythonRuntime uses Pyodide 0.28.3 (CPython compiled to WebAssembly via Emscripten) running in a Node.js Worker thread.
Support Tiers
| Tier | Label | Meaning |
|---|---|---|
| 1 | Bridge | Implemented via worker-to-host RPC through the system driver. |
| 2 | Pyodide built-in | Available through Pyodide’s bundled standard library. |
| 3 | Blocked | Intentionally disabled; deterministic error on use. |
Compatibility Matrix
Bridge capabilities (Tier 1)
These features use the same permission-gated system driver as the Node runtime.| Capability | API | Notes |
|---|---|---|
| File read | secure_exec.read_text_file(path) | Requires permissions.fs. Returns EACCES if denied, ENOSYS if no filesystem adapter. |
| File write | open(path, "w") | Requires permissions.fs. |
| Network | secure_exec.fetch(url, options) | Requires permissions.network. Returns EACCES if denied, ENOSYS if no network adapter. |
| Environment | os.environ | Filtered by permissions.env. Only allowed keys are visible. |
| Working directory | os.getcwd() / os.chdir() | Per-execution cwd override supported. |
| stdio | print() / input() | print() streams through onStdio hook. input() reads from stdin option. |
Standard library (Tier 2)
These modules are available through Pyodide’s bundled CPython standard library. This is not an exhaustive list; most pure-Python stdlib modules work.| Module | Status |
|---|---|
json | Full support. |
os | Partial. os.environ, os.getcwd(), os.chdir(), os.makedirs(), os.path.* work. Subprocess and signal APIs are unavailable (Emscripten limitation). |
sys | Full support. sys.modules persists across warm executions. |
math | Full support. |
re | Full support. |
datetime | Full support. |
collections | Full support. |
itertools | Full support. |
functools | Full support. |
typing | Full support. |
io | Full support. |
hashlib | Full support. |
base64 | Full support. |
struct | Full support. |
dataclasses | Full support. |
enum | Full support. |
abc | Full support. |
Blocked (Tier 3)
| Feature | Error |
|---|---|
micropip / package installation | ERR_PYTHON_PACKAGE_INSTALL_UNSUPPORTED: Python package installation is not supported in this runtime |
loadPackagesFromImports | Same as above. |
loadPackage | Same as above. |
| Subprocess spawning | secure_exec.spawn is not exposed. |
Execution Model
Warm state
The Python interpreter stays alive perPythonRuntime instance. Consecutive exec() and run() calls share module globals and state:
Return values
run() returns structured results with value and globals:
Serialization limits
Values crossing the bridge are serialized with these caps:| Limit | Value |
|---|---|
| Object depth | 8 levels |
| Array elements | 1024 |
| Object properties | 1024 |
| Total payload | 4 MB |
| Circular references | Converted to [Circular] |
Differences from Node Runtime
| Node | Python | |
|---|---|---|
| Isolation | V8 isolate (isolated-vm) | Pyodide in Worker thread |
memoryLimit | Configurable | Not available |
timingMitigation | "freeze" / "off" | Not available |
| Return shape | exports (ESM default export) | value + globals |
| Module system | CJS / ESM | Python imports |
| Package installation | Host node_modules overlay | Blocked by design |
| Subprocess | child_process (permission-gated) | Not available |
| HTTP server | http.createServer (bridge) | Not available |
| State model | Fresh per execution | Warm (persistent across calls) |
Timeout Behavior
Same contract as Node runtime:cpuTimeLimitMssets the CPU budget per execution- On timeout:
code: 124,errorMessage: "CPU time limit exceeded" - Worker restarts after timeout for deterministic recovery
- Subsequent executions work normally after a timeout