# RustPython Package Coverage

nanocode-python embeds a modified RustPython interpreter, not CPython. This experiment measures installation and small execution probes for a fixed package matrix, not general Python compatibility.

## Upstream Credit

[RustPython](https://github.com/RustPython/RustPython) is the upstream interpreter, maintained by the RustPython Team and contributors. Its [earliest commit](https://github.com/RustPython/RustPython/commit/4050ea2f9ac5b1b65658d53ec81554f89e8888a8) names Shing Lyu. That history does not make a sole-creator claim.

The [vendored manifest](https://github.com/nanocodexyz/nanocode/blob/6ed92be87b3a2f704a7af857a2237b3fccafbb27/crates/patches/rustpython-vm/Cargo.toml) identifies RustPython, and its [MIT license](https://github.com/nanocodexyz/nanocode/blob/6ed92be87b3a2f704a7af857a2237b3fccafbb27/crates/patches/rustpython-vm/LICENSE) retains the RustPython Team copyright. The Python language and bundled standard-library code have separate origins and [PSF license terms](https://github.com/nanocodexyz/nanocode/blob/6ed92be87b3a2f704a7af857a2237b3fccafbb27/crates/patches/rustpython-pylib/Lib/PSF-LICENSE), including the history of Guido van Rossum's Python.

Bundled scientific libraries are not original nanocode work. The [license inventory](/experiments/evidence/fork-python.json) links retained NumPy, pandas, Matplotlib, Pillow, and supporting-library notices. NumPy and pandas retain BSD terms, Matplotlib its own agreement, and Pillow the MIT-CMU license.

## Measured Change

The baseline [SDK `6d58e23`](https://github.com/nanocodexyz/nanocode-ts/commit/6d58e2328f8dba8d6360195112eacff5b8c608e1) passes 22 of 40 fixed probes in each of three trials. The published [SDK `c9e92eb`](https://github.com/nanocodexyz/nanocode-ts/commit/c9e92eb906d19b958553e2ee85f57319579d4976) passes 33 of the same 40 in each of three trials. [Per-package run records](/experiments/evidence/fork-python-trials.json) retain each result and the raw-file hash.

| Stage              | Passed Probes | Repeated Counts | Evidence                                                        |
| ------------------ | ------------: | --------------- | --------------------------------------------------------------- |
| Baseline SDK       |       22 / 40 | 22, 22, 22      | [Run and commit](/experiments/evidence/fork-python-trials.json) |
| Intermediate SDK   |       32 / 40 | 32, 32, 32      | [Run and commit](/experiments/evidence/fork-python-trials.json) |
| Resolver candidate |       33 / 40 | 33, 33, 33      | [Run and commit](/experiments/evidence/fork-python-trials.json) |
| Published SDK      |       33 / 40 | 33, 33, 33      | [Run and commit](/experiments/evidence/fork-python-trials.json) |

The fixed-matrix proportion changes from 55% to 82.5%. This is a census of these probes, not random package sampling. Three identical repetitions do not establish a population confidence interval. [Evidence and statistical limits](/experiments/evidence/fork-python.json) include the original descriptive intervals without presenting them as population coverage estimates.

## What Changed

[Import recovery and installation order](https://github.com/nanocodexyz/nanocode/commit/db0e3a08b569ac98f1f10648446fbaa56b3f07dc) fix interpreter integration. The [pip resolver change](https://github.com/nanocodexyz/nanocode-ts/commit/5d0ec7064a766390ca3f788d1caaff92e83f36dd) adds a RustPython compatibility dependency and an index-version constraint. ABI encode/decode execution, not metadata alone, checks the added package path.

The final [published release](https://github.com/nanocodexyz/nanocode-ts/releases/tag/build-c9e92eb) packages those changes with the [pinned interpreter source](https://github.com/nanocodexyz/nanocode/commit/6ed92be87b3a2f704a7af857a2237b3fccafbb27). The [artifact record](/experiments/evidence/fork-python.json) identifies the tarball, interpreter, and data hashes.

## Checks and Limits

Trials run in Node with fresh package filesystems and frozen PyPI responses. The [run policy](/experiments/evidence/fork-python.json) records memory, timeout, interpreter fuel, and fixture hashes. No latency improvement is claimed.

`pip check` is an unconditional-success stub and is not validation. Distribution hashes are checked against frozen PyPI metadata, but regenerated installed RECORD entries do not provide per-file integrity verification. The direct wheel, URL, and directory installation policy is unchanged.

## What Remains

The final [raw projection](/experiments/evidence/fork-python-trials.json) still fails the statsmodels, SciPy, scikit-learn, lxml, cryptography, PyArrow, and Polars probes. Passing small NumPy, pandas, or Matplotlib probes does not establish their full APIs.

The package suite alone does not prove low-memory, Workers, or actual iOS-app support. The separate runtime experiments below do not change its package-coverage count.

## What Runs Where

The November 18, 2026 follow-up runs a fixed pandas workload on actual Cloudflare Workers. Polars runs locally and through a separate Node backend, not on provider Workers. [Run rows, source hashes, programs, fixtures, and limits](/experiments/evidence/python-workers.json) distinguish each environment.

> [!NOTE]
> The [source change](https://github.com/nanocodexyz/nanocode-ts/commit/620c5b025f0743ed41d7ad4a2b9fa7fb7be13694) is included in [SDK build-878f938](https://github.com/nanocodexyz/nanocode-ts/releases/tag/build-878f938). These measurements use the frozen candidate artifacts, not a new benchmark of that release. Measured and integrated source hashes remain separate. The Polars artifact is not packaged in the published SDK.

| Workload                              | Actual Environment           | Result                                                                                     | Evidence                                                  |
| ------------------------------------- | ---------------------------- | ------------------------------------------------------------------------------------------ | --------------------------------------------------------- |
| pandas, fixed 9,066,102-byte CSV      | Cloudflare Workers           | Baseline and candidate each pass three eager and three chunked runs                        | [Worker rows](/experiments/evidence/python-workers.json)  |
| pandas, 200,000-row analysis and PNG  | Node, public Bash entrypoint | Baseline and candidate pass three runs per SDK budget. Explicit chunking also passes three | [Node rows](/experiments/evidence/python-workers.json)    |
| Polars, eager and record-aware chunks | Local workerd                | Each passes three runs. This is not provider memory qualification                          | [Local rows](/experiments/evidence/python-workers.json)   |
| Polars, analysis and PNG              | Separate Node HTTP backend   | Three runs pass through the public offload API                                             | [Backend rows](/experiments/evidence/python-workers.json) |

### Worker Limits

The pandas candidate retains a compressed snapshot: 9,734,469 bytes becomes 3,138,468 bytes, saving 6,596,001 bytes. This measures retained payload, not peak isolate memory. [Payload lengths and artifact hashes](/experiments/evidence/python-workers.json) identify the unchanged interpreter and data.

Cloudflare's documented isolate limit is 128 MiB. Held, touched allocations of 64 MiB pass three controls. Allocations of 256 MiB produce `exceededMemory` in three provider Tail events. No exact isolate peak was available. [Control rows](/experiments/evidence/python-workers.json) exclude the separate single-buffer RangeError diagnostic.

No cold-start speedup is established. Baseline requests follow fresh-service creation, while final candidate requests follow version updates with warm static-asset caches. The [timing rows and intervals](/experiments/evidence/python-workers.json) retain that confound. A Durable Object has the same isolate limit, not more memory.

### Chunking Tradeoff

For pandas analysis and charting, Wasm linear memory is 127,664,128 bytes. Explicit chunking reduces it to 107,806,720–108,331,008 bytes, but runs slower. Both produce identical numbers and PNGs. SDK budget arguments of 80 and 512 MiB are not process or isolate caps. [All trials](/experiments/evidence/python-workers.json) remain Node-only.

| Node Workload     | Mean Execution |    95% Mean Interval | Evidence                                                |
| ----------------- | -------------: | -------------------: | ------------------------------------------------------- |
| pandas candidate  |    3,628.66 ms | 2,492.87–4,764.46 ms | [Three runs](/experiments/evidence/python-workers.json) |
| Explicit chunking |    4,475.95 ms | 4,230.33–4,721.56 ms | [Three runs](/experiments/evidence/python-workers.json) |

These are descriptive Student-t intervals, not population p95 estimates. Both rows use the same one-core quota. Earlier baseline runs use two cores, so their timing difference cannot establish an SDK speedup. [Measurement definitions](/experiments/evidence/python-workers.json) separate linear memory, RSS, and charged cgroup memory.

### Polars Boundaries

The reduced Polars build compiles seven explicit wrapper features, not a complete streaming engine. Its compressed Wasm falls from 14,627,791 to 13,978,327 bytes, still above Cloudflare's 10 MiB upload limit. It was not deployed to Workers. [Build inputs and artifact hashes](/experiments/evidence/python-workers.json) identify this experimental artifact.

`scan_csv(...).collect()` and `collect(engine='streaming')` panic for the missing `new_streaming` feature in all three trials each. `read_csv(...).lazy()` reads eagerly first. Native batched CSV also fails on this platform. [Successes and failures](/experiments/evidence/python-workers.json) remain separate.

Caller-written, record-aware chunks reduce linear memory from 67,371,008 bytes to 39,518,208–39,714,816 bytes, about 41% less across three runs. This is not lower total memory: local process RSS increases, and the full input remains in the host filesystem. [Exact programs and measurements](/experiments/evidence/python-workers.json) retain this limitation.

### Backend Selection

The candidate's opt-in `python.sci.mode = 'all'` selects `PythonSci.remote` before loading a local interpreter. The backend uses `PythonSci.serve` in a separate Node process. Each measured request dispatches once, with no local module or image load. This is deterministic preselection, not automatic OOM retry or replay. [API runs](/experiments/evidence/python-workers.json) include the chart workload.

The backend uses an actual Linux 512 MiB cgroup. A 256 MiB allocation succeeds, and a 640 MiB control is OOM-killed. Chart runs pass three times, but process RSS reaches 551,714,816–575,565,824 bytes, above 512 MiB. Charged cgroup memory is a different metric. [Controls and run rows](/experiments/evidence/python-workers.json) preserve both.

Use at least 1 GiB for a production backend, then qualify its own limits. This experiment does not prove Vercel 512 MiB support or deploy a Vercel, Durable Object, Container, or Sandbox backend. No model or wallet calls occur in these runtime experiments. [Scope and provenance](/experiments/evidence/python-workers.json) record those boundaries.
