# Cloudflare Python Workers: A Visual Guide to Talk Python Episode 568

**Guide**: https://talkpython.fm/guides/568/cloudflare-python-workers
**Episode**: [Talk Python to Me #568: Cloudflare Python Workers](https://talkpython.fm/episodes/show/568/cloudflare-python-workers)
**Featuring**: Hood Chatham (Pyodide and Emscripten maintainer at Cloudflare), Gyeongjae Choi (Cloudflare engineer and Pyodide maintainer), Dominik Picheta (Cloudflare Workers runtime engineer)
**Published**: November 10, 2026

**TL;DR:** Cloudflare Python Workers are generally available. Your FastAPI, Django or Flask app ships as plain Python files and runs on CPython compiled to WebAssembly, inside V8, at more than 350 locations near your users. Getting there took two years of systems work: memory snapshots for cold starts, real sockets for databases, a clean way to stop Python at the CPU limit, and a packaging PEP that lets maintainers publish WebAssembly wheels to PyPI. It's a great fit for I/O-bound APIs and a poor one for heavy number crunching.

Where does your Python code actually run? For most of us the answer is a server in one region. Maybe a VM in Virginia, maybe a container in Frankfurt. Every request from Sydney or São Paulo makes the round trip to that one place and back.

Cloudflare Python Workers change the answer. Cloudflare runs a JavaScript runtime on its servers in more than 350 locations, and Pyodide, which is CPython compiled to WebAssembly, runs inside it. Put the two together and your Python runs wherever your users happen to be, with no region to choose.

The road there started somewhere unexpected. Hood Chatham, now a Pyodide maintainer at Cloudflare, is a mathematician by training, and found that mathematicians don't like to install software because they assume it won't work. The browser was the one platform everyone already had. That led to Pyodide, shortly after Mozilla had stepped away from it, and to a list of everything that was broken. Instead of getting defensive, the maintainer keeping the project alive said to come fix it. A math postdoc and a stint at Anaconda later, that work led Hood to Cloudflare to help build Python Workers.

This guide covers how it works and when to use it: the path a request takes, deploying and testing locally, which frameworks and Python features work, the engineering behind fast cold starts and database sockets, the limits, PEP 783's WebAssembly wheels, and where Python on WebAssembly goes next.

## What are Cloudflare Python Workers?

![The Transitive Property of Compute. Three linked circles: Python into the Browser (Pyodide), Browser into the Server (Cloudflare), Python into the Server (At the Edge). Pyodide puts Python into the browser, Cloudflare puts the browser into the server, and together Python arrives at the server, distributed globally.](https://blobs.talkpython.fm/guides/568/02.webp?cache_id=2c527192)

Python Workers are two ideas stacked on top of each other. The first is Pyodide, a build of CPython compiled to WebAssembly so that Python can run anywhere a JavaScript engine runs. Its home is the browser, but it works in any JavaScript runtime, Node and Bun included. It doesn't run in WebAssembly-only runtimes such as Wasmtime, because Pyodide leans on JavaScript for everything that touches the outside world.

The second idea is Cloudflare Workers. Cloudflare took V8, the JavaScript engine behind Chrome, and put it on its servers in more than 350 locations around the world. Code deployed as a Worker runs on whichever of those machines is closest to the person making the request.

Stack the two and you get CPython, inside WebAssembly, inside V8, inside Cloudflare's network. Michael joked that it works by the transitive property, which is a fair description of what the image above shows.

Pyodide can run in your users' browsers, but Python Workers don't. They run on Cloudflare's own machines, which happen to be near your users. That matters because it gives your code the whole Cloudflare platform - databases, object storage, queues - rather than whatever a phone's browser can offer.

Why go to all this trouble? Latency. If your API lives in us-east-1, every user in Europe or Asia pays for the trip across an ocean on every call. Run the code next to them and that cost mostly goes away.

It took a while. Hood started on Python Workers in October 2023. A beta followed about six months later, in spring 2024, and getting to general availability took more than two more years. GA was announced on September 21 in a post written by the three guests. Most of that time went into the unglamorous parts: letting people install real packages, making cold starts fast, adding sockets so database drivers work, and making sure the runtime can be stopped without breaking. The rest of this guide covers each of those. With GA, Python is a fully supported Workers language with access to everything else on the platform.

> "Pyodide is kind of this crazy idea of like, we should put Python into the browser. And then Cloudflare is kind of this crazy idea of like, we should put the browser into the server."
>
> Hood Chatham

**Resources**

- [Python Workers GA announcement](https://blog.cloudflare.com/python-workers-ga/)
- [Python Workers docs](https://developers.cloudflare.com/workers/languages/python/)
- [Cloudflare global network](https://www.cloudflare.com/network/)
- [Pyodide](https://pyodide.org)

## How a request reaches your Python code on Cloudflare

![Anatomy of an Edge Request. A layered cutaway: The User; Point of Presence, routes to the nearest of 350+ global locations; Workers Runtime, C++ host for the V8 JavaScript engine; WebAssembly, Pyodide executing inside V8; Your Code, executing near the user. Sidebar: no round trip to a single US or EU data center.](https://blobs.talkpython.fm/guides/568/03.webp?cache_id=1467f5e2)

Follow a single request from the outside in. A user's browser or app calls your API. Cloudflare's routing sends that connection to the nearest point of presence, one of its 350-plus data center locations. That machine runs the Workers runtime. The runtime hosts V8. V8 runs Pyodide as WebAssembly. And Pyodide runs your Python.

At no point in that chain do you pick a location. The same routing that makes a CDN fast decides which node answers each user, so someone in Southeast Asia gets a node in Southeast Asia without you doing anything. Think of Workers as a CDN for programs instead of files.

You don't compile anything to WebAssembly yourself. The interpreter and the WebAssembly builds of packages come prebuilt, and you deploy ordinary Python source.

How is this different from AWS Lambda? Both are serverless in the sense that you hand over a function and never manage a machine. But a Lambda function lives in a region you pick, like us-east-1 or Frankfurt. Every caller travels to that region. With Workers there's no region setting at all. That's why Dominik Picheta, who works on the Workers runtime, considers Workers "more serverless than AWS Lambda": they just show up wherever your users are. Michael agreed. Lambda simply claimed the word first.

Words like edge, serverless and cloud are closer to marketing terms than technical ones, so they don't say much on their own. The mechanics are simpler to pin down: your code is copied to every location and runs at the one nearest each user.

The trade-off comes from the same design. A program that runs everywhere has to be small, start fast and work within tight limits on memory and CPU. Later sections cover how Python was made to fit, and where it still doesn't.

> "I always describe this as being like a CDN, except for instead of with static assets, it distributes programs and then runs the programs on your data."
>
> Hood Chatham

**Resources**

- [Cloudflare Workers](https://developers.cloudflare.com/workers/)
- [V8 JavaScript engine](https://v8.dev)
- [AWS Lambda](https://aws.amazon.com/lambda/)

## Deploying Python Workers and developing locally with workerd

![Symmetric Local Development. A laptop labeled Local Environment, running workerd open-source core, beside a package labeled uv package manager / PyWrangler, and Absolute Parity with a laptop over a world map labeled Global Network, Cloudflare edge network, 350+ global locations. Code hot-reloads locally.](https://blobs.talkpython.fm/guides/568/08.webp?cache_id=20c1373d)

Do you have to build WebAssembly to deploy a Python Worker? No. All the WebAssembly pieces, the interpreter included, come prebuilt. What you deploy is your Python source plus its dependencies. Cloudflare bundles them up, distributes them around the world, and each location loads your app into Pyodide when a request needs it.

Dependencies go through PyWrangler, a uv-based tool from Cloudflare. uv can install packages built for WebAssembly into your project, and PyWrangler uses that to bundle whatever your app needs. This wasn't the original plan. Early on, Workers only allowed the set of packages that ship with Pyodide itself. That turned out not to be flexible enough, so the team switched to letting you install whatever packages you want.

To make this concrete, here's the workflow from Cloudflare's docs. You list packages in `pyproject.toml` as usual:

```toml
dependencies = [
    "fastapi"
]
```

Then a handful of commands take you from a new project to a deployed Worker:

```bash
uvx --from workers-py pywrangler init
uv run pywrangler dev
uv run pywrangler deploy
```

Pure Python packages work, as do packages with WebAssembly builds on PyPI or in Pyodide. More on how those builds get made in the PEP 783 section.

The local story is where Workers stand out. The core of the Workers runtime is open source as workerd, and it's on GitHub. Cloudflare's Wrangler CLI wraps it so you don't have to drive it by hand. You run your Worker locally, edit its files, they reload automatically, and you send requests to see what happens.

Why does that matter? workerd is the same runtime that serves production, so behavior you see locally is behavior you'll see on the network. Compare that with most cloud platforms. You can install Kubernetes on your laptop and run pods, but that isn't the same as Amazon's managed Kubernetes service.

> "basically, you can run the same code in the same runtime in your local machine and the prods. You can test everything that happens in prod in your local machine."
>
> Gyeongjae Choi

**Resources**

- [workerd (open source Workers runtime)](https://github.com/cloudflare/workerd)
- [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/)
- [uv](https://docs.astral.sh/uv/)

## Running FastAPI, Django and Flask on Cloudflare Workers

![The Standard Adapters. A bridge labeled Standard Interfaces (ASGI / WSGI) links Familiar Web Frameworks (Django, FastAPI, Flask) to the Cloudflare Workers Runtime. Caption: frameworks don't do raw network I/O, so the platform acts as the web server and you pass the application object to the runtime.](https://blobs.talkpython.fm/guides/568/06.webp?cache_id=47636fc2)

What do people actually build with Python Workers? Mostly API servers: endpoints that take a request, talk to a database or another service, and send back JSON. That's why Cloudflare's examples lean so heavily on FastAPI. If you know how to write a FastAPI app, you already know how to write a Python Worker.

The only real change is how the app starts. Normally you'd hand your app to a server like uvicorn or gunicorn. On Workers, the platform is the server, so you hand the app object to Cloudflare instead. Here's the quick-start example from Cloudflare's FastAPI docs:

```python
from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def read_root():
    return {"Hello": "World"}

from workers import asgi
Default = asgi.entrypoint(app)
```

The examples have a single route, but that's just to keep them short. There's no limit on how many endpoints your app can have. Any FastAPI app you'd write elsewhere is fair game.

The same goes beyond FastAPI. Cloudflare ships general-purpose ASGI and WSGI adapters, so Django, Flask and the other frameworks that speak those interfaces run too. There's one caveat: a framework that tries to start threads will have problems, since threads aren't available in the runtime (more on that in the next section).

Why does this work so smoothly? Because of the interfaces themselves. ASGI and WSGI exist so that a web framework never does its own network I/O. The server accepts the connection, parses the request and passes it in. That's exactly the shape Workers need, since all real I/O in the runtime goes through JavaScript.

Contrast that with a library that does its own networking, such as urllib3. Its normal way of opening connections doesn't work in Pyodide, so it needs a separate code path just for Pyodide. urllib3 has added one, but every framework would need the same treatment without the adapters.

Michael's view is that ASGI and WSGI were among the best things to happen to Python on the web, because one interface lets a framework plug into many runtimes. Cloudflare's runtime is now one of them.

> "It's amazing for us. Yeah, because they don't try to do IO directly."
>
> Hood Chatham

**Resources**

- [FastAPI](https://fastapi.tiangolo.com)
- [Django](https://www.djangoproject.com)
- [Flask](https://flask.palletsprojects.com)
- [ASGI specification](https://asgi.readthedocs.io)
- [urllib3](https://github.com/urllib3/urllib3)

## Threads, subprocesses and asyncio in Pyodide

![Concurrency and the WebLoop. A large gear, Host JavaScript Event Loop (handles all actual I/O), meshes with a blue gear, Pyodide WebLoop (Python's asyncio). A separate blocking Python loop would freeze the host loop, so WebLoop subscribes to the host JavaScript loop and bridges async/await.](https://blobs.talkpython.fm/guides/568/11.webp?cache_id=4d91cb23)

Before you port anything, know that a pure Python package won't automatically work on Pyodide. A package with no compiled code can still depend on parts of the operating system that a JavaScript runtime doesn't have.

The usual suspects are threading, multiprocessing, subprocesses and native sockets. None of them work in Pyodide running in a browser. Outside the browser, in Node.js or Cloudflare Workers, the picture improves a bit, because those runtimes have access to more. Sockets now work on Workers, for example (the sockets section covers how). Threads and subprocesses still don't. So if a library spins up a thread pool behind the scenes, or shells out to a command, it won't run in a Python Worker.

What about asyncio? It works, and it had to. Everything in a browser is asynchronous. Before Pyodide had a good asyncio story, calling into JavaScript meant chaining `.then()` callbacks. That's tolerable in JavaScript, where a lambda can span several lines, but painful in Python, where lambdas are limited to a single expression. Making asyncio work was one of Hood Chatham's first big projects after becoming a Pyodide maintainer.

The piece that makes it work is WebLoop, Pyodide's asyncio event loop. A normal asyncio loop owns its thread and spins on its own, waiting for I/O. WebLoop doesn't. It subscribes to the host JavaScript event loop and lets that loop drive it.

Why not just run a regular Python loop next to JavaScript's? Because in a JavaScript runtime, all real I/O happens on the JavaScript loop. A separate Python loop couldn't do any I/O of its own. Worse, while it was spinning and waiting, it would block the JavaScript loop, which is the only thing that could finish the I/O it was waiting for. WebLoop avoids that deadlock by never owning the loop in the first place.

As a Worker author, you write async code the way you normally would. `async def` views in FastAPI, `await` on your database calls and HTTP requests, all of it maps onto the JavaScript event loop underneath. What you can't do is reach for threads or subprocesses to get concurrency.

> "everything in a browser is async. So when there wasn't a good asyncio story for Pyodide, it was like really rough to use it"
>
> Hood Chatham

**Resources**

- [asyncio docs](https://docs.python.org/3/library/asyncio.html)
- [Bun](https://bun.sh)
- [Wasmtime](https://wasmtime.dev)

## How memory snapshots speed up Python cold starts

![Overcoming the Cold Start. Traditional Initialization: Bootstrap Interpreter, Load Standard Library, Run Top-Level Imports, Execute App. Memory Snapshot: capture memory state after imports, then jump to Execute App. Imports are executed code; a patched loader and allocator replay library addresses.](https://blobs.talkpython.fm/guides/568/04.webp?cache_id=980946dc)

A serverless platform starts your code on demand. When a request arrives at a location where your app isn't already running, it has to start from scratch. That's a cold start, and for Python it's expensive. The interpreter bootstraps itself, loads the standard library, then runs your app's top-level code, imports and all. Only then can it handle the request.

That work comes out identical every time: same code, same imports, same result in memory. Doing it again on every cold start, at every location, is pure waste.

Memory snapshots skip it. Cloudflare runs the startup work once, captures the resulting memory, and restores that snapshot on later cold starts. Your app picks up right where startup ended, as the bottom row of the image above shows. It was the first thing Hood Chatham worked on after joining Cloudflare, with about two months of research before writing any code.

Why is that hard? Because Python has no line between startup and runtime. When the interpreter starts, it bootstraps, then evaluates code until there's nothing left to evaluate. Top-level code and a function call look the same to it. Even an `import` statement is ordinary code: it compiles to bytecode that tells importlib to find a file and execute it. So a snapshot has to impose a boundary the language never defined.

Optimizing implementations run into the same issue. PyPy and GraalPy want to evaluate as much as they can at compile time, which is called partial evaluation. It's a different technique from a memory snapshot, but it needs the same missing line between what can be done ahead of time and what has to wait. Antonio Cuni is building SPy, short for Static Python, a language that bakes a compile-time versus run-time distinction in from the start.

Native extensions make snapshots harder still. Importing a compiled library relocates it in memory, allocating space for its globals and functions at some address. A restored snapshot is only valid if every library lands at the same address again. The fix is a patched dynamic loader that records where each library was placed, plus a patched `malloc` that replays those exact addresses on restore. Complicated? Very. Hood presented the work, and the startup-versus-runtime problem behind it, at the Python Language Summit.

> "It was a lot of fun. It's really horrible."
>
> Hood Chatham

**Resources**

- [Memory Snapshots for CPython (Python Language Summit)](https://blog.python.org/2026/09/language-summit-2026-memory-snapshots/)
- [PyPy](https://pypy.org)
- [GraalPy](https://www.graalvm.org/python/)
- [SPy](https://github.com/spylang/spy)

## Socket support in Pyodide, and Postgres through Hyperdrive

![The Networking Miracle. A gear labeled Synchronous: Python System Calls and Linux Sockets joins, through a Stack Switch Mechanism and a pendulum, a gear labeled Asynchronous: Host JavaScript Event Loop and Node.js Socket APIs. Node.js socket APIs wired into Pyodide make Hyperdrive work.](https://blobs.talkpython.fm/guides/568/05.webp?cache_id=31a556f6)

Browsers have never given web pages raw TCP sockets, so Pyodide, born in the browser, never had socket support. For a lot of web code that's fine, since HTTP can go through the JavaScript runtime. But relational databases don't speak HTTP. To talk to PostgreSQL or MySQL, a driver opens a TCP connection, so without sockets there's no database.

Supporting Hyperdrive, and with it sockets, was one of the main goals before Python Workers went GA, and the socket work was Gyeongjae Choi's project. The Workers runtime supports Node.js's socket APIs, so the team wired those into Pyodide. When Python code makes a socket system call, Pyodide routes it to the corresponding Node.js socket call underneath.

That sounds straightforward until you look at the calling conventions. Node's socket APIs are all asynchronous: you start an operation and get called back later. Linux socket system calls are mostly synchronous: `recv` blocks until data arrives, then returns it. Code written against the Linux model expects to wait in place.

The bridge is stack switching. When a synchronous socket call comes in, Pyodide switches away from the Python stack, lets the JavaScript event loop turn until the I/O completes, then switches back and returns the result, as if the call had simply blocked. The pendulum in the image above swings to JavaScript and back. None of this is visible to the caller. It works for C code too, so a C library that uses libc's socket functions just works.

Sockets are what make Hyperdrive usable from Python, since Hyperdrive is built on TCP connections. Hyperdrive is Cloudflare's answer to a real problem with running code everywhere: your database probably still lives in one place. Opening a fresh connection from a far-off Worker to that database on every request would be slow. Hyperdrive puts proxies at the edge that keep pools of open connections to your origin PostgreSQL or MySQL database, so reads and writes skip the connection setup. You can also turn on caching for data that doesn't change often.

So the full chain is a Python database driver calling a socket function, which stack switches into a Node.js socket API, which talks to a nearby Hyperdrive proxy holding a warm connection to your database.

> "the socket APIs in Node, of course, are all asynchronous, but most of the socket system calls that you have in Linux are synchronous calls."
>
> Hood Chatham

**Resources**

- [Hyperdrive](https://www.cloudflare.com/products/hyperdrive/)
- [PostgreSQL](https://www.postgresql.org)
- [Node.js](https://nodejs.org)

## D1, R2, Queues and Workers AI: the Cloudflare platform from Python

![The Edge Platform Topography. The Python Worker (Central Execution) at the center, orbited by D1, globally replicated SQLite alongside the worker; R2 Storage, zero-egress fee object storage; Workers AI, edge inference endpoints; Hyperdrive, edge proxies keeping warm connection pools.](https://blobs.talkpython.fm/guides/568/09.webp?cache_id=47f437bc)

Running code close to users only helps if the code can reach its data quickly. That's what the rest of Cloudflare's developer platform is for, and with GA, Python Workers get the same building blocks as every other Worker.

**D1** is a database built on SQLite. You get a SQLite database local to your Worker that you can read and write, and Cloudflare replicates it around the world for you. It scales with your Workers, so there's no database server to size. For anyone who already likes SQLite for web apps because it's just a library and a file, D1 is a natural extension of that. Dominik Picheta is one of those people and had been building web apps on SQLite before Workers. If your mental model of SQLite is a toy, it's worth updating: it's a very fast database.

**R2** is object storage that works like Amazon S3. The name is a small joke: shift each character of "S3" back by one and you get R2. The real difference is cost. R2 has no egress fees, so you don't pay bandwidth charges every time someone downloads a file, which is often where an S3 bill comes from.

**Hyperdrive** connects Workers to a PostgreSQL or MySQL database you already run elsewhere, through pooled connections at the edge. The previous section covers how sockets make it work from Python.

**Queues, Workflows and Workers AI** round out the list. Queues give you background work between Workers. Workflows handle multi-step processes. Workers AI runs model inference at the edge, near your users. The platform adds something new nearly every month, so this list will keep growing.

How does Python reach all of these? Python Workers consume these services the same way other Workers do, and the platform takes care of the rest. That's a deliberate part of the design: the Python runtime doesn't have to understand how D1 replicates or how R2 stores objects. How D1 settles two writes from opposite sides of the world at the same moment is the platform's problem, not your Worker's.

Many of these services don't require Workers at all. You could use R2 purely as cheaper object storage for an app hosted somewhere else.

> "One of the great things about the design of Python workers is that we just consume these things. We don't need to know how they work."
>
> Hood Chatham

**Resources**

- [D1](https://www.cloudflare.com/products/d1/)
- [R2 Object Storage](https://www.cloudflare.com/products/r2/)
- [Queues](https://developers.cloudflare.com/queues/)
- [Workers AI](https://www.cloudflare.com/products/workers-ai/)
- [SQLite](https://www.sqlite.org)

## Python Worker limits: memory, CPU time and the free tier

![The Physics of Compute Limits. A pressure vessel labeled Compute Capacity: 128 MB Memory and 10ms CPU Time Limit, with an OS-Level Signal Interceptor releasing a Graceful Halt. A JavaScript exception would skip finally blocks; an OS-level signal forces a safe halt, shared with Rust workers.](https://blobs.talkpython.fm/guides/568/10.webp?cache_id=65144542)

Every Worker runs inside a box with fixed walls, and it's worth knowing where they are before you design around them.

- **Memory:** 128 MB per Worker. According to Cloudflare's limits page, that covers the JavaScript heap and WebAssembly allocations together, so the Python interpreter and your data share it.
- **CPU time:** 10 milliseconds per request on the free plan, and up to five minutes on paid plans (30 seconds by default). CPU time counts only time spent computing. Waiting on a network request or a database query doesn't count toward it.
- **Requests:** the free plan includes 100,000 requests a day.

That last number is bigger than it sounds. Many hobby projects and small apps live well under it, and you can run a simple FastAPI app without paying Cloudflare anything. The free tier extends to storage too: Gyeongjae Choi, who used Cloudflare as a student for exactly this reason, recalls about 10 GB of R2 storage free. The numbers change, so check the limits page rather than trusting a guide (this one included).

Ten milliseconds of compute is not much, though. So what happens when your code runs out? Handling that well was one of the quieter projects between beta and GA.

The naive way to stop a runaway Worker is for JavaScript to throw an exception that can't be caught into the runtime. That unwinds the entire call stack at once, without running any `finally` or `except` blocks. Think about what Python code puts in `finally`: releasing locks, flushing buffers, closing files. Skip all of that and the interpreter is left holding locks nobody will release, with half-written state everywhere. The runtime is broken.

Cloudflare's fix treats Python more like a real operating system process. When the CPU limit hits, the time limiter delivers a proper signal to the Python and Emscripten "operating system" running inside the runtime. Python stops what it's doing in an orderly way, the cleanup code runs, and control goes back to Cloudflare. Getting the signal delivered correctly took a lot of careful work.

Rust Workers had the very same problem, so Python Workers and Rust Workers now share the same solution.

> "JavaScript throws a non catchable exception into the runtime and forcibly unwinds all of the call stack without executing finally blocks"
>
> Hood Chatham

**Resources**

- [Cloudflare Workers limits](https://developers.cloudflare.com/workers/platform/limits/)
- [Workers pricing](https://developers.cloudflare.com/workers/platform/pricing/)
- [Emscripten](https://emscripten.org)
- [Rust on Cloudflare Workers](https://developers.cloudflare.com/workers/languages/rust/)

## PEP 783: WebAssembly wheels on PyPI

![The WebAssembly Packaging Frontier. Pure Python (setuptools) runs anywhere. Native Extensions (SciPy, pandas) needed flaky 4-hour cross-compiles in Pyodide's CI. WebAssembly Wheels (PEP 783): maintainers add a Pyodide target to cibuildwheel and publish to PyPI. About 5% of packages have C, C++ or Rust.](https://blobs.talkpython.fm/guides/568/07.webp?cache_id=21e7f4f7)

Packages come in two kinds as far as WebAssembly is concerned. Pure Python packages, like setuptools, need no compiling. They're interpreted, so they run anywhere Python runs (subject to the threads-and-subprocesses caveats from earlier). Packages with C, C++ or Rust inside are different. That code has to be compiled for each platform, and for Pyodide the platform is Emscripten, the WebAssembly toolchain.

Until 2025, the Pyodide team did all of that compiling themselves. NumPy, SciPy, Matplotlib and the rest of the scientific stack were cross-compiled in Pyodide's own CI, around 300 packages in all. A full build took three to four hours, even for a one-line change to Pyodide. And it was flaky, because building Python packages means running arbitrary Python build code, which breaks in creative ways. It also doesn't scale. PyPI is approaching a million packages, and one small team can't build the long tail.

PEP 783, Emscripten packaging, moves the work to the people who own the packages. It defines a WebAssembly wheel platform so maintainers can build Pyodide wheels and publish them to PyPI like any other wheel. It was accepted after about a year of discussion, thanks to a lot of work by Hood Chatham. Gyeongjae Choi had already moved Pyodide's package build system into external repositories, and the team standardized it so a maintainer doesn't need a special setup: add the Pyodide platform to cibuildwheel and the wheels come out of their existing CI. Per cibuildwheel's docs, it's one option, run on Linux or macOS:

```bash
cibuildwheel --platform pyodide
```

How much of PyPI does this affect? Less than you'd think. Hood's off-the-cuff estimate is that only about 5% of packages contain C, C++ or Rust. The rest are pure Python already.

Progress is tracked on a site called Are We PEP 783 Yet, which covers the most popular packages, since most applications depend on some of the top 500. Green means the package publishes WebAssembly wheels on PyPI. Blue means Pyodide still builds it. Yellow means it isn't supported yet.

The Pyodide team hasn't stopped building, though. It still builds some packages, and still carries a compiler wrapper that rewrites compiler arguments to work around toolchain bugs. Compiler regressions are the biggest remaining worry. Moving Pyodide to Python 3.15 meant going up about ten Emscripten releases, and almost every one had some regression that broke a package build. To stay confident the platform works, the team expects to keep building a range of packages themselves so these problems show up before downstream maintainers hit them.

> "even if you make a little one line change in Pyodide that needs to run CI for like three and four hours to build."
>
> Gyeongjae Choi

**Resources**

- [PEP 783, Emscripten Packaging](https://peps.python.org/pep-0783/)
- [Are we PEP 783 yet?](https://pyodide.github.io/are-we-pep783-yet/)
- [cibuildwheel](https://github.com/pypa/cibuildwheel)
- [PyPI](https://pypi.org)

## Is Python on Cloudflare Workers good for data science?

![Architectural Suitability Matrix. Sweet Spot (I/O-bound): API servers, routine business logic, database proxies, streaming data processing (Polars). Anti-Pattern (CPU/memory-bound): heavy data science (SciPy with 100+ shared libraries), massive pandas DataFrames over 128MB, GPU or SIMD work.](https://blobs.talkpython.fm/guides/568/12.webp?cache_id=7dcd2860)

Short answer: mostly no, and the people who built it say so. Workers aren't a platform with a lot of computing power. There are no GPUs and no SIMD, and each request gets a small slice of CPU. What real Workers tend to contain is far less glamorous than a model or a notebook.

So what's the sweet spot? I/O-bound work, the left column of the image above. An API that pulls data from a database, reshapes it a little and sends it on spends most of its time waiting, and waiting is cheap here. The same goes for business logic and for apps that push a lot of bytes without doing much computation on them.

Can you do any data work at all? Small jobs, yes. Picture a student with a Parquet file of 20,000 records who wants to run a quick query and draw a graph. In principle that works: you can load pandas, load a Parquet reader, and produce the chart, as long as the data isn't too big.

The trouble starts with the heavyweight packages. SciPy is the cautionary tale. Importing it pulls in more than 100 shared libraries, which doesn't really work within a Worker, and after a long journey getting it to work in Pyodide, Hood Chatham calls it the most horrible package.

Gyeongjae Choi is more cautious about pandas, too. Libraries like pandas and DuckDB weren't designed for an environment as memory-limited as Workers. The approach that fits is streaming: process data in pieces instead of loading whole DataFrames into memory. That favors tools like Polars over a load-everything pandas workflow. The catch is that a lot of the Python data ecosystem, especially older packages, wasn't built with streaming in mind.

There's a better option for one common case: sharing research. Instead of running the analysis on Cloudflare, put Pyodide and your data on a static site and run everything in the reader's browser, the way JupyterLite does. Lots of people already do exactly that, and the end user's device pays for the compute.

It also solves a problem research groups know well. The tools a group can use are often limited to what its least technical member can install and get working. When the notebook runs in a browser tab, there's nothing to install, which is the same reason Hood went looking for Python in the browser in the first place.

> "A lot of the workers that I've looked at are big piles of boring business logic."
>
> Hood Chatham

**Resources**

- [pandas](https://pandas.pydata.org)
- [Polars](https://pola.rs)
- [SciPy](https://scipy.org)
- [JupyterLite](https://jupyterlite.readthedocs.io)

## The state of Python on WebAssembly, and PEP 818

![The Open Frontier. A sea chart with a Python compass rose and Terra Incognita: WebAssembly. Current State: Emscripten is a Tier 3 CPython platform; PEP 818 proposes an FFI to JavaScript. Invitation: an uncrowded space for systems programmers. Promise: deploy plain Python files to 350+ cities.](https://blobs.talkpython.fm/guides/568/13.webp?cache_id=c2b7861d)

Python Workers sit on top of a bigger effort: making CPython a solid citizen on WebAssembly. Hood Chatham and Gyeongjae Choi recently gave a EuroPython talk on exactly that, and the short version is that things are good. A few years ago, bug reports were often baffling. Now less and less goes wrong.

The platform underneath is Emscripten. It's a compiler toolchain with Clang as its front end, and it ships JavaScript implementations of system calls and of a file system. The result is something like a JavaScript version of a musl-based Linux, and that's the target Python gets compiled for.

Where does that stand in CPython itself? Emscripten is a Tier 3 platform. CPython runs it in CI, but on a best-effort basis: a change is allowed to break it, it isn't a release blocker, and there are no official Emscripten release builds.

Why no releases? Because a plain Emscripten Python can't do much. In a JavaScript runtime, every interaction with the outside world goes through JavaScript, the same way everything on Linux goes through C. Without a way to call JavaScript, Python can't make HTTP requests or receive user input, so nobody would want that build as it is.

That's what PEP 818 is meant to fix. It proposes adding the core of Pyodide's foreign function interface to CPython, as a module called `jstypes`, modeled on `ctypes`. Just as `ctypes` lets Python call into C, `jstypes` would let it call JavaScript functions. It went to the Steering Council for review shortly before this episode was recorded.

Want to try Python Workers? Start with an I/O-bound app, one that moves a lot of bytes without much computation, and you may be surprised how many users the free tier handles. Report anything broken on Cloudflare's Discord. To go deeper on the pieces, Talk Python Training's [Modern APIs with FastAPI and Python](https://training.talkpython.fm/courses/modern-fastapi-apis?utm_source=talkpythondeepdive) covers the framework Cloudflare's examples use, [Async Techniques and Examples in Python](https://training.talkpython.fm/courses/python-concurrency-deep-dive?utm_source=talkpythondeepdive) covers the async model a runtime without threads depends on, and [Python Web Apps that Fly with CDNs](https://training.talkpython.fm/courses/fast-python-web-apps-with-cdn?utm_source=talkpythondeepdive) covers the CDN ideas Workers build on.

And if you'd rather work on the platform than on top of it, WebAssembly is wide open. Plenty of fundamental pieces near the operating system and libc are still missing, and few people work on them, so if something you want doesn't work, you can wedge yourself in and fix it.

> "you feel like Linux works too well for you to get into, then like I think WebAssembly is a really great space because a lot more of that stuff is just I think no one has ever even tried to make it work."
>
> Hood Chatham

**Resources**

- [PEP 818, Adding the Core of the Pyodide FFI to Python](https://peps.python.org/pep-0818/)
- [PEP 11, CPython Platform Support](https://peps.python.org/pep-0011/)
- [Emscripten](https://emscripten.org)
- [ctypes docs](https://docs.python.org/3/library/ctypes.html)
- [WebAssembly](https://webassembly.org)
- [Pyodide on GitHub](https://github.com/pyodide/pyodide)

---

Listen to the full episode: https://talkpython.fm/episodes/show/568/cloudflare-python-workers
Episode show notes as Markdown: https://talkpython.fm/episodes/show/568/cloudflare-python-workers.md
