Skip to content

pymode

Full CPython 3.13 on Cloudflare Workers. Write Python handlers with direct access to KV, R2, D1, and TCP — compiled to a 1.8MB gzipped WASM binary using zig cc.

Cloudflare’s Python Workers (Pyodide-based) are in limited beta with an uncertain roadmap. PyMode takes a different approach — upstream CPython compiled to WASM via zig cc, purpose-built for Cloudflare Workers with Durable Objects.

Upstream CPython 3.13

No patches or forks. Vanilla CPython compiled with zig cc to wasm32-wasi. See bundled modules.

1.8MB Gzipped

5.7MB raw, 1.8MB gzipped — vs Pyodide’s 20MB/6.4MB. Fits well within CF’s 10MB limit.

Native CF Bindings

Direct WASM host imports for KV, R2, D1, TCP, and HTTP. No JS interop overhead.

5ms Cold Starts

Optional Wizer snapshots reduce cold start from ~28ms to ~5ms.

Request → Worker (stateless) → PythonDO (Durable Object)
python.wasm (_start)
on_fetch(request, env)
KV / R2 / D1 / TCP
Response → Client

Each request gets its own sandboxed Python runtime inside a Durable Object. The WASM stack is instrumented with Asyncify so host imports (HTTP fetch, KV reads, TCP recv) suspend and resume transparently.

HTTP Fetch

fetch("https://api.example.com") calls the host directly — no network stack in WASM.

Parallel Execution

spawn() launches child Durable Objects with separate 30s CPU budgets and 128MB memory.

Package Ecosystem

Pure-Python packages work out of the box. C/Rust extensions (numpy, pydantic_core) compile to WASM variants. AI frameworks (langchain, langgraph, instructor) tested and working.

Multi-File Projects

Standard Python imports work. Organize your project with packages, modules, and pyproject.toml.