Python Workers Redux: Wasm Snapshots and Native uv Tooling
Briefly

Python Workers Redux: Wasm Snapshots and Native uv Tooling
"One of my biggest points of criticism of Python is its slow cold start time. I especially notice this when I use it as a scripting language for CLIs. The startup time of a simple .py script can easily be in the 100 to 300 ms range, whereas a C, Rust, or Go program with the same functionality can start in under 10 ms. This becomes even more frustrating when piping several scripts together, because the accumulated startup latency adds up quickly."
"The company introduced a new architecture that utilizes memory snapshots to bypass the initialization phase. Furthermore, WebAssembly (Wasm) powering Python Workers enables this capability by bypassing the need for Address Space Layout Randomization (ASLR), a security feature that typically makes memory snapshotting complex and insecure in native operating systems. In the blog post, the authors explain that by executing the top-level scope once at deployment and capturing a snapshot of the Wasm linear memory, Cloudflare enables quick Worker restoration, resulting in speed gains."
Cloudflare redesigned Python Workers using WebAssembly and memory snapshotting to bypass typical Python initialization, producing near-instant cold starts. The top-level scope is executed once at deployment and the Wasm linear memory snapshot is captured to enable rapid Worker restoration. Bypassing Address Space Layout Randomization in the Wasm environment simplifies secure snapshotting. Heavy packages like fastapi and pydantic now load in about one second instead of nearly ten. Benchmarks show Python Workers start 2.4× faster than AWS Lambda (without SnapStart) and 3× faster than Google Cloud Run. The environment expands package compatibility and streamlines workflow via the uv package manager.
Read at InfoQ
Unable to calculate read time
[
|
]