Public · Technical deep-dive

SlimePython PoC 0–11 — Hybrid Bit-Exact Isolate, measured

Real source, conversion code, measurements and reproduction steps for PoC 0–11, run on real hardware (WSL2 / CPython 3.12.3 / RustPython 0.5.0 / wasmtime 40 / x86_64). All figures are measured on a single machine with a pinned CPython. Per the AI-Trap-17 (fabricating empirical claims) policy, we do not claim 100% over the untested space.

Public deep-dive. To make “third-party reproducible” real, the samples, conversion code, measurements and reproduction scripts are all public (download below). Transparency is the moat. Questions / business: contact us.

0. Model (2 regions + 2 tiers)

RegionTargetGuarantee
StaticSlot IR → pure Ruststructurally bit-exact
Dynamickept as Python, delegated to a deterministic CPython Isolatebit-exact in the same environment (contradictions preserved; only non-determinism rejected)
tierimplfidelityspeedportability
Fullstatic-CPython Isolate40/40 bit-exactat/above python3x86_64/glibc
LightRustPython → WASM19/20 (only abc message wording)~3–6×portable to WASM/aarch64

1. Isolate runner (shared by all PoCs, ~20 lines)

The dynamic Python fragment is handed as-is to an embedded CPython under deterministic constraints; stdout is compared to python3 by SHA-256.

// PoC 2/3 Isolate runner — PYTHONHASHSEED=0, run the .py in embedded CPython
use pyo3::prelude::*;
fn main() {
    std::env::set_var("PYTHONHASHSEED", "0");
    std::env::set_var("PYTHONUNBUFFERED", "1");
    let path = std::env::args().nth(1).unwrap();
    let code = std::fs::read_to_string(&path).unwrap();
    Python::with_gil(|py| {
        if let Err(e) = py.run_bound(&code, None, None) { e.print(py); std::process::exit(1); }
        let _ = py.run_bound("import sys\nsys.stdout.flush()", None, None);
    });
}

Dynamic sample (constructs §13 rejected — still bit-exact)

# monkey patch + decorator + kwargs forwarding (PoC 2 #15)
def add_log(fn):
    def wrapped(*args, **kwargs): return f"LOG:{fn(*args, **kwargs)}"
    return wrapped
class Service:
    def compute(self, x): return x * 100
Service.compute = add_log(Service.compute)   # runtime class rewrite
print(Service().compute(7))                   # LOG:700 — Python==Isolate, SHA-256 match

2. Correctness — 40/40 bit-exact cumulative

PoCScopeResult
1Any ×55/5
2*args/**kwargs + dynamic getattr/setattr + monkey ×1515/15
320 real-world dynamic (metaclass / descriptors / dataclass / generators / eval-exec …)20/20

3. Full tier speed — “slow” was a build choice (PoC 4→6)

The embedding first looked ~18–38% slower than python3 on hot loops (the PoC 4 crossover). Root cause: the PIC in the shared libpython.so (GOT/PLT indirection). /usr/bin/python3 statically embeds libpython (non-PIC) (no libpython line in ldd).

# PoC 6: static build from source = production recipe (no stubs, PIE/ASLR kept)
./configure --prefix=<pfx> --disable-shared --enable-optimizations --with-lto
make -j$(nproc) && make altinstall
# link the Isolate against the static libpython (PyO3 shared=false / prepare_freethreaded_python)
PYO3_CONFIG_FILE=pyo3-source.cfg LIBPY_KIND=source cargo build --release
M (work/launch)iso_source / python3
1 (short-lived)0.60× (faster)
1,000,000 (hot)0.99× (at parity)

Only the shared .so is slow (1.19–1.34×) — isolated with a Py_BytesMain runner (identical CLI path) + distro's non-PIC / PIC / .so 3 variants (PoC 4.5/5).

4. Light tier — RustPython → WASM (PoC 7/8)

19/20 bit-exact on the same samples (only difference: the abc exception message wording; semantics match). Cross-compiled to wasm32-wasip1 and run under wasmtime — wasm = native RustPython 20/20. The Light tier runs on WASI, where embedding CPython cannot be built.

5. Auto-routing + runtime profile (PoC 9/10)

# PoC 9 router (static): reject = non-determinism only. 0 mis-routes / 20
if target in ("wasm","aarch64"):        return Decision("light", "Full unavailable")
if sig.unsupported:                     return Decision("full", "unsupported")
if sig.exc_text_dep and exact_exceptions: return Decision("full", "exact exception text")
if sig.hot_loop and perf == "fast":     return Decision("full", "avoid hot-loop slowdown")
return Decision("light", "Light is sufficient")

PoC 10: compute-heavy code invisible to static analysis (range(var), recursion) is caught by a runtime profile → routed to Full next time. hot_varrange Light 633ms→Full 212ms (3×), hot_fib 1260ms→135ms (9×).

6. What we reject = non-determinism only (PoC 11, 4 measured classes)

ClassExamplesHandling
A. preserved by defaulthash/set order (seed0), dict, float math, GIL threadingbit-exact as-is
B. preserved via Isolate injectionunseeded random, timedeterministic via fixed seed/clock (value canonicalized)
C. preserved in same env onlyos.environ, file I/O, subprocesssame env matches; cross-env is the CI envelope
D. truly non-deterministicid(), default repr (address), getpid, uuid4outside the guarantee (= Python's nature)

“Contradictions preserved, only non-determinism rejected.” The irreducible core is just memory addresses, process ID, OS entropy.

7. Download (full reproduction)

Reproduction needs CPython 3.12 / Rust 1.93 / PyO3 0.22 / RustPython 0.5 / wasmtime. See run_*.sh in each PoC directory. Questions: contact us.