Skip to content

feat(cpython): drop low-use stdlib modules for agent scripts - #2582

Merged
chaliy merged 1 commit into
mainfrom
claude/project-thread-io7h59
Oct 7, 2026
Merged

chaliy merged 1 commit into
mainfrom
claude/project-thread-io7h59

Conversation

@chaliy

@chaliy chaliy commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What changed

The CPython guest no longer ships stdlib modules that agent scripts rarely use. These are dropped:

  • Test, profiling and packaging tools: unittest, doctest, cProfile, profile, pstats, trace, tabnanny, pyclbr, modulefinder, pickletools, compileall, zipapp.
  • Rare formats: dbm, shelve, plistlib, wave, netrc.
  • Interactive helpers: cmd, rlcompleter, tty, pty.
  • bz2, lzma and compression.zstd shims. Their C codecs were never built, so importing them already failed.
  • concurrent.interpreters.

gzip, zipfile (deflate), tarfile (plain/gzip), shutil, xml, csv, json and sqlite3 are unchanged. breakpoint() still prints a notice and continues.

The workload priority is now recorded in knowledge (runtimes/cpython-wasm.md "Workload priority"). The main use is agents running python3 for scripted logic such as processing a file. A low-use module needs a concrete agent use case before it is added back.

Why

Every shipped module costs crate bytes, and those bytes are the budget for preloading modules that agents actually import.

Before / After

  • Stdlib zip: 3,576,098 → 3,156,718 bytes.
  • bashkit-cpython-wasm .crate: 8,642,486 → 8,216,210 bytes (cap 10 MiB).
  • import unittest: Before, ~0.2 s per call. After, ModuleNotFoundError.
  • print(1) per call: unchanged.

Risk

  • Low. Scripts that import a dropped module now get ModuleNotFoundError. The full list is in L-CPY-009.

Checklist

  • Tests added or updated (stdlib_is_bytecode_only asserts the drops and that gzip/zipfile/tarfile/shutil still import; doctest test replaced by breakpoint_continues); cargo test --features cpython --test integration cpython: 113 passed
  • Backward compatibility considered

Generated by Claude Code

Agents run python3 for scripted logic (file processing, data transforms).
Stop shipping unittest, doctest, profilers, compileall/zipapp, dbm/shelve,
plistlib, wave, netrc, cmd, tty/pty and the bz2/lzma/zstd shims (no C
codecs in the guest). Stdlib zip 3.58 -> 3.16 MB. Record the workload
priority in knowledge.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit 28de65e Commit Preview URL

Branch Preview URL
Oct 07 2026, 06:06 PM

@chaliy
chaliy merged commit 46c8965 into main Oct 7, 2026
36 checks passed
@chaliy
chaliy deleted the claude/project-thread-io7h59 branch October 7, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant