Cloudflare Python Workers
Panelists
Episode Deep Dive
Guests Introduction and Background
This episode features three guests from Cloudflare who together brought Python to Cloudflare's global Workers platform.
Hood Chatham is a mathematician by training who started out in Lisp and ML-family languages. Hood's first real Python was an email scheduler for a math seminar (in Python 2.7). While building research math software, Hood found that mathematicians won't install software on their computers, which made the browser look like the ideal universal computing platform. That path led to Pyodide right after Mozilla had stepped back from the project. Hood showed up with a list of complaints, and maintainer Roman Yurchak responded with an invitation to fix them. Hood went on to spend most of a National Science Foundation math postdoc improving Pyodide, then worked at Anaconda on PyScript, and joined Cloudflare in October 2023 to make Python Workers happen. Hood is a Pyodide maintainer, an Emscripten maintainer, and the author of PEP 783 (Emscripten packaging) and PEP 818 (adding the core of the Pyodide foreign function interface to Python).
Gyeongjae Choi (who goes by "Jay" on the show) started programming as a kid with Visual Basic and C. They picked up Python in their second year of university, in a data science course built around NumPy and SciPy, and "just fell in love with Python." Gyeongjae began contributing to Pyodide around 2021 and maintained it for four to five years. Along the way they moved Pyodide's package build system out into external repositories. That open source work led to an invitation to join Cloudflare, where they have worked on Python Workers for about a year, including the socket support that makes Hyperdrive and real database drivers work.
Dominik Picheta got into Python as a kid. Dominik was using Visual Basic .NET, wanted to move to Linux, and followed friends who used Python. Frustrated that Python was interpreted, Dominik went on to become a core developer of the Nim programming language. After working at Meta, Dominik joined Cloudflare's Workers runtime team and was the person who first experimented with Pyodide inside Cloudflare and got it running, which kicked off the Python Workers effort.
- Pyodide: pyodide.org
- Pyodide on GitHub: github.com/pyodide/pyodide
- Nim: nim-lang.org
- PyScript: pyscript.net
What to Know If You're New to Python
This episode is mostly about where Python runs, not how you write it. It helps to have a rough picture of web APIs, how Python talks to the operating system, and what WebAssembly is.
- WebAssembly and Pyodide: WebAssembly (WASM) is a portable binary format that runs inside JavaScript engines like V8, the engine behind Chrome and Node.js. Pyodide is CPython compiled to WebAssembly, and every Python Worker runs on it.
- ASGI and WSGI: These are the standard interfaces between Python web frameworks (FastAPI, Django, Flask) and the server that runs them. Because frameworks speak these interfaces instead of doing raw network I/O, Cloudflare can run them unmodified through adapters, with no uvicorn or gunicorn required.
- Pure Python vs. compiled wheels: Most packages on PyPI are pure Python and run anywhere Python runs. Packages with C, C++, or Rust inside (like NumPy) need to be compiled for each platform, and this is the problem PEP 783 solves for WebAssembly.
- Cold starts and serverless: On serverless platforms, your code is loaded on demand when a request arrives. The time spent starting the interpreter and importing modules is called the "cold start," and much of the engineering in this episode goes into making it shorter.
- async and await: Everything in a JavaScript runtime is asynchronous, so asyncio support matters a lot here. Knowing what an event loop is will help you follow the discussion of sockets, I/O, and Pyodide's WebLoop.
Key Points and Takeaways
1. Python Workers are now generally available: Python in the browser, browser in the server
The headline of the episode is that Cloudflare Python Workers are generally available, announced on September 21 in a blog post by the three guests. Hood summed up the architecture this way: Pyodide is the idea of putting Python into the browser, Cloudflare is the idea of putting the browser into the server, and combining the two gets Python into the server. Your code runs on CPython compiled to WebAssembly, inside V8, at more than 350 Cloudflare locations, so it executes close to your users instead of making a round trip back to a single region like us-east-1. The work took a long time. Hood started in October 2023, a beta took about six months, and getting to GA took over two more years. Most of that time went into packaging, cold start performance, sockets, and making the runtime robust. GA means Python is now a first-class, officially supported Workers language with access to the whole Cloudflare developer platform.
- Python Workers GA announcement: blog.cloudflare.com/python-workers-ga
- Python Workers docs: developers.cloudflare.com/workers/languages/python
- Cloudflare global network: cloudflare.com/network
- Pyodide: pyodide.org
2. How a request reaches your Python code
Dominik walked through the flow of a request. A user connects to the nearest Cloudflare point of presence, which runs the Workers runtime. That runtime hosts V8, and V8 runs Pyodide in WebAssembly, which runs your Python. As a developer you never choose the location; routing sends each user to a nearby node, much like a CDN. Hood described Workers as "like a CDN, except instead of static assets, it distributes programs and then runs the programs on your data." Michael compared this with AWS Lambda, where functions are pinned to a region such as us-east-1 or Frankfurt. The guests argued that Workers are actually more serverless than Lambda, because you don't even have to decide where your code is placed. Hood also noted that words like "edge," "serverless," and "cloud" are more marketing terms than technical ones, so the actual mechanics are what matter.
- Cloudflare Workers: developers.cloudflare.com/workers
- V8 JavaScript engine: v8.dev
- AWS Lambda: aws.amazon.com/lambda
3. Deploying plain Python files and developing locally with workerd
You never build WebAssembly yourself. As Gyeongjae explained, the WebAssembly pieces are prebuilt, and you deploy your Python source plus its dependencies. Dependencies are installed with uv, which can install packages built for WebAssembly into your project. Early on, Cloudflare allowed only a set of built-in packages that Pyodide provided. They decided that wasn't flexible enough and built PyWrangler, a uv-based tool that lets you install whatever packages you need. For local development, the Workers runtime is open source as workerd, and the Wrangler CLI wraps it, so you edit files, they reload automatically, and you send requests locally. Gyeongjae highlighted that because workerd is the same runtime that runs in production, you can test production behavior on your own machine. Michael pointed out that this is unusual, since a local Kubernetes cluster is not the same thing as Amazon's managed Kubernetes service.
- workerd (open source Workers runtime): github.com/cloudflare/workerd
- Wrangler CLI: developers.cloudflare.com/workers/wrangler
- uv: docs.astral.sh/uv
4. FastAPI, Django, and Flask run through ASGI and WSGI adapters
The main use case for Workers is API servers, which is why Cloudflare's examples lean heavily on FastAPI. If you know how to write a FastAPI app, you already know how to write a Python Worker. Instead of calling uvicorn.run(), you hand your app object to the platform. There is no limit on how many endpoints your app can have. Cloudflare ships general-purpose ASGI and WSGI adapters, so FastAPI, Django, Flask, and similar frameworks work as long as they don't try to start threads. Hood credited these standard interfaces for making this possible, because frameworks that speak ASGI or WSGI don't do I/O directly. Libraries that do their own networking, like urllib3, need a separate Pyodide-specific code path (which urllib3 has added).
- FastAPI: fastapi.tiangolo.com
- Django: djangoproject.com
- Flask: flask.palletsprojects.com
- ASGI specification: asgi.readthedocs.io
- urllib3: github.com/urllib3/urllib3
5. Memory snapshots make cold starts fast
Memory snapshots were the first thing Hood worked on at Cloudflare, with about two months spent researching before writing any code. Every time a Python app cold starts, it does the same work: bootstrapping the interpreter, loading the standard library, and running top-level module code and imports. Snapshots capture the resulting memory once and restore it on each cold start, which cuts startup time. Python has no built-in distinction between "startup time" and "runtime," since even import statements are just code being executed, so a snapshot has to impose that distinction on the language. Hood compared it to partial evaluation in optimizing implementations like PyPy and GraalPy, and mentioned Antonio Cuni's SPy (Static Python), which builds a compile-time vs. run-time distinction into the language. Restoring snapshots with native extensions takes "crazy magic": a patched dynamic loader records where each shared library was relocated, and a patched malloc replays those exact addresses on restore. Hood presented this work at the Python Language Summit.
- Memory Snapshots for CPython (Python Language Summit): blog.python.org/2026/09/language-summit-2026-memory-snapshots
- PyPy: pypy.org
- GraalPy: graalvm.org/python
- SPy: github.com/spylang/spy
6. Real sockets make real database drivers and Hyperdrive work
Browsers have never offered raw TCP sockets, so Pyodide never had socket support. You need sockets to talk to relational databases, though, and Gyeongjae made this a key goal before GA. The solution wires the Node.js socket APIs that the Workers runtime supports into Pyodide, so socket system calls in Python (and in C code that uses libc) reach real network connections. Hood explained the tricky part: Node's socket APIs are asynchronous, but Linux socket system calls are synchronous. Each system call has to stack switch, let the JavaScript event loop turn until the I/O finishes, and then switch back, all invisibly to the calling code. This is what makes Hyperdrive work with Python. Hyperdrive is a network of edge proxies that keep connection pools to your origin PostgreSQL or MySQL database, with optional query caching.
- Hyperdrive: cloudflare.com/products/hyperdrive
- PostgreSQL: postgresql.org
- Node.js: nodejs.org
7. The platform building blocks: D1, R2, Queues, and Workers AI
Python Workers get the same platform services as every other Worker. D1 is a SQLite-based database that lives next to your worker and is replicated around the world for you. Dominik, a longtime SQLite fan, called it a natural extension of how Dominik already builds web apps. Michael asked how concurrent writes from Southeast Asia and London get reconciled, and mentioned Litestream's write-ahead-log streaming as a possible model. The guests didn't know the internals. Hood said one of the nice things about Python Workers' design is that they "just consume these things." R2 is S3-compatible object storage. Its name comes from shifting each character of "S3" back by one, and its big selling point is no egress fees. The lineup also includes Queues, Workflows, and Workers AI for inference at the edge, and Michael noted that many of these services can be used without Workers at all.
- D1: cloudflare.com/products/d1
- R2 Object Storage: cloudflare.com/products/r2
- Queues: developers.cloudflare.com/queues
- Workers AI: cloudflare.com/products/workers-ai
- SQLite: sqlite.org
- Litestream: litestream.io
8. Limits and a generous free tier
Dominik laid out the main limits: 128 MB of memory per worker, plus CPU time limits of 10 milliseconds per request on the free plan and up to five minutes on paid plans. CPU time means compute, not wall-clock time, so time spent waiting on I/O doesn't count the same way. The free tier includes about 100,000 requests per day, which Michael noted covers many hobby and small apps. Gyeongjae, who used Cloudflare as a student because of its free tier, mentioned roughly 10 GB of free R2 storage. The current numbers are on Cloudflare's limits page, and the guests suggested checking there rather than relying on memory.
- Cloudflare Workers limits: developers.cloudflare.com/workers/platform/limits
- Workers pricing: developers.cloudflare.com/workers/platform/pricing
9. Interrupting Python gracefully when time runs out
One of the less visible GA projects was handling a worker that hits its CPU limit. The naive approach is for JavaScript to throw an uncatchable exception into the runtime, which unwinds the whole call stack without running any finally or except blocks. Locks never get released, buffers never get flushed, and the Python runtime ends up broken. Instead, Cloudflare delivers a proper signal to the Python and Emscripten "operating system" inside the runtime, so execution stops cleanly and control returns to Cloudflare. Hood noted that Rust Workers had the same problem, so both languages now share the same solution. It's a good example of the systems work needed to make Python behave correctly in an environment it was never designed for.
- Emscripten: emscripten.org
- Rust on Cloudflare Workers: developers.cloudflare.com/workers/languages/rust
10. PEP 783 brings WebAssembly wheels to PyPI
Until 2025, the Pyodide team cross-compiled every package with native code (NumPy, SciPy, Matplotlib, and around 300 others) in Pyodide's own CI. A full build took three to four hours, even for a one-line change, and it was flaky. PEP 783, authored by Hood and accepted after about a year of discussion, defines an Emscripten wheel platform so package maintainers can build and publish WebAssembly wheels to PyPI themselves. Gyeongjae standardized the build tooling so that maintainers can add one Pyodide platform to cibuildwheel and get Emscripten wheels in their own CI. Dominik stressed that this is how the long tail of PyPI comes to Pyodide, since the Pyodide team can't build everything. Hood added some perspective: only about 5% of PyPI packages contain C, C++, or Rust, so most packages are pure Python already. The "Are we PEP 783 yet?" site tracks the top packages. Green means wheels are on PyPI, blue means Pyodide still builds them, and yellow means not yet supported.
- PEP 783, Emscripten Packaging: peps.python.org/pep-0783
- Are we PEP 783 yet?: pyodide.github.io/are-we-pep783-yet
- cibuildwheel: github.com/pypa/cibuildwheel
- PyPI: pypi.org
- Python Packaging Council governance (PEP 772): peps.python.org/pep-0772
11. The state of Python on WebAssembly and PEP 818
Hood and Gyeongjae recently presented "Python Everywhere: The State of Python on WebAssembly" at EuroPython, and the short version is that things are good, with far fewer confusing bugs than a few years ago. Emscripten, a Clang-based toolchain that provides JavaScript implementations of system calls and a file system, is a Tier 3 supported platform in CPython. That means it runs in CI on a best-effort basis, isn't a release blocker, and has no official release builds. Hood argued that an upstream Emscripten Python without a way to call JavaScript can't do much useful work (no HTTP, no user input), because in a JavaScript runtime everything goes through JavaScript, the way everything on Linux goes through C. Hood's new PEP 818, recently submitted to the Steering Council, proposes adding the core of Pyodide's foreign function interface to CPython as a jstypes module, modeled after ctypes. The remaining pain is compiler regressions. Updating to Python 3.15 meant moving up about ten Emscripten releases, and almost every one broke some package build. Pyodide still keeps a compiler wrapper that rewrites arguments to work around these bugs.
- Python Everywhere: The State of Python on WebAssembly (EuroPython): youtube.com/watch?v=HklunTc9giA
- PEP 818, Adding the Core of the Pyodide FFI to Python: peps.python.org/pep-0818
- PEP 11, CPython Platform Support: peps.python.org/pep-0011
- Emscripten: emscripten.org
- ctypes docs: docs.python.org/3/library/ctypes.html
12. What works and what doesn't: threads, subprocesses, and asyncio
Pure Python doesn't always mean "works on Pyodide." Gyeongjae explained that packages relying on threading, multiprocessing, subprocesses, or native sockets won't work in the browser. In Node.js and Cloudflare Workers, more becomes available (sockets now, for example), but threads and subprocesses still don't work. asyncio does work, and getting it working was one of Hood's first big projects as a maintainer, since everything in a browser is asynchronous and the alternative was chains of .then() callbacks. Pyodide's event loop, WebLoop, subscribes to the host JavaScript event loop instead of running its own. Hood explained why it has to: all real I/O happens on the JavaScript loop, so a separate Python loop spinning on its own would block the very loop that has to finish the I/O. Pyodide also runs in any JavaScript runtime, including Node and Bun, but not in WebAssembly-only runtimes like Wasmtime.
- asyncio docs: docs.python.org/3/library/asyncio.html
- Bun: bun.sh
- Wasmtime: wasmtime.dev
13. Data science is not the sweet spot, but the browser might be
Michael asked whether Workers fit data science. Hood was candid: no GPUs, no SIMD, and not much compute, so Hood wouldn't recommend it, and described most real Workers as "big piles of boring business logic." Small jobs can work. You can load pandas and a Parquet file of around 20,000 records and produce a graph. SciPy is another story: it pulls in more than a hundred shared libraries, and Hood called it "the most horrible package" in Pyodide's history. Gyeongjae pointed out that with 128 MB of memory you should process data as streams rather than loading whole DataFrames, which favors tools like Polars over pandas-style workflows. A better fit for sharing research may be to put Pyodide and your data on a static site and run everything in the reader's browser, JupyterLite-style, so the end user's device pays for the compute.
- pandas: pandas.pydata.org
- Polars: pola.rs
- SciPy: scipy.org
- NumPy: numpy.org
- JupyterLite: jupyterlite.readthedocs.io
14. Best fit: I/O-bound apps, and WebAssembly as an open frontier
The guests' closing advice was practical. Dominik said Workers shine for I/O-bound apps that push a lot of bytes without doing much CPU work, and that you'll be surprised how many users you can serve even on the free tier. Gyeongjae runs many of their own hobby apps on Python Workers and asked people to report anything broken on Cloudflare's Discord. Hood pitched WebAssembly as a great place to contribute. If you're interested in operating systems, how libc works, or other low-level details, but feel that "Linux works too well" to find a way in, WebAssembly has many basic pieces nobody has built yet. The community is small, so it's easy to find something you wish worked and fix it yourself.
- Python Workers docs: developers.cloudflare.com/workers/languages/python
- WebAssembly: webassembly.org
- Pyodide on GitHub: github.com/pyodide/pyodide
Interesting Quotes and Stories
From complainer to maintainer: Hood showed up to Pyodide, then barely being kept alive by Roman Yurchak after Mozilla stepped back, with a list of what was broken. Instead of getting defensive, Roman extended an invitation to fix it, and that eventually led to Hood's role at Cloudflare.
"I showed up and I was like, here are all the things that are bad about what's currently going on. ... But he was like, oh, well, why don't you come fix those things? And so he made me into a maintainer." -- Hood Chatham
"They weren't defensive at all. They were just like, 'Great, we want this to be better. If you want to make it better, please make it better.'" -- Hood Chatham
Mathematicians don't install software: Hood's path to WebAssembly began with colleagues who wouldn't install anything.
"I found out that mathematicians don't like to install software on their computer. They assume it won't work." -- Hood Chatham
"If there's a lowest common denominator effect, where like the technology you can use in your research is only the things that the least technically competent person in your group can use." -- Hood Chatham
The one-line architecture summary:
"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. And so when you put Python into the browser and you put the browser in the server, that's a funny way of getting Python into the server." -- Hood Chatham
"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
Open source as a career path: Gyeongjae's years of Pyodide contributions led straight to a job.
"It's really interesting that you start to contribute on open source and you get a job with that. That's something that all the open source contributors are hoping to." -- Gyeongjae Choi
Three to four hour CI runs: Before PEP 783, the Pyodide team built everything themselves.
"Even if you like make a little like one line change in Pyodide that needs to run CI for like three and four hours to build." -- Gyeongjae Choi
"Well, we have this horrifying compiler wrapper that rewrites the compiler arguments to fix all the problems." -- Hood Chatham
On memory snapshot internals:
"It was a lot of fun. It's really horrible." -- Hood Chatham
More serverless than serverless:
"I would actually consider, I mean, workers in general to be more serverless than AWS Lambda. ... Just because you don't have to worry about where you're placing your workers. They just show up wherever your users are." -- Dominik Picheta
The curly braces debate: A side conversation about multi-line lambdas got heated in a friendly way.
"I think it should have had curly braces, and then it could have had multi-line lambdas. I think curly braces are the way." -- Hood Chatham
"Oh, you're going to cause a fight." -- Michael Kennedy
An invitation to systems programmers:
"If 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 like, no one has ever even tried to make it work." -- Hood Chatham
Shared inspiration: Both Michael and Hood called Gary Bernhardt's talk "The Birth & Death of JavaScript" one of the best talks ever, and recommended listeners watch it for the backstory on Emscripten and running everything on JavaScript runtimes.
- The Birth & Death of JavaScript: destroyallsoftware.com/talks/the-birth-and-death-of-javascript
Key Definitions and Terms
- Pyodide: A distribution of CPython compiled to WebAssembly via Emscripten, with a foreign function interface for calling JavaScript. It runs in browsers and JavaScript runtimes like Node.js, Bun, and Cloudflare Workers.
- Emscripten: A Clang-based compiler toolchain that targets WebAssembly and provides JavaScript implementations of system calls and a file system. Hood described it as something like a JavaScript version of a musl-based Linux.
- Tier 3 platform: A CPython platform support level (defined in PEP 11) where the platform runs in CI on a best-effort basis, can be broken by changes, and isn't a release blocker.
- Point of presence (PoP): One of Cloudflare's 350+ data center locations worldwide. Requests are routed to the nearest one.
- workerd: The open source core of the Cloudflare Workers runtime, used both in production and for local development.
- Wrangler: Cloudflare's CLI for developing and deploying Workers, which wraps workerd for local runs.
- PyWrangler: A uv-based tool from Cloudflare that installs any Python package (including WebAssembly wheels) into a Python Worker.
- Cold start: The delay when a new instance of your code starts up to handle a request, including interpreter startup and imports.
- Memory snapshot: A saved image of the Python runtime's memory after startup and top-level imports, restored on later cold starts to skip repeated work.
- Partial evaluation: A compiler technique that evaluates parts of a program ahead of time. Hood compared it to memory snapshots because both need a line between "startup" and "runtime" that Python doesn't define.
- Stack switching: A technique that lets a synchronous system call (like a socket read) pause, let the JavaScript event loop finish async I/O, and then resume as if the call had simply blocked.
- WebLoop: Pyodide's asyncio event loop, which subscribes to the host JavaScript event loop instead of running its own.
- Foreign function interface (FFI): A mechanism for calling code written in another language. PEP 818 proposes a
jstypesmodule, modeled onctypes, for calling JavaScript from Python. - Egress fees: Charges for data transferred out of a cloud provider. R2's lack of egress fees is its main difference from S3.
- Connection pooling: Keeping a set of open database connections ready for reuse. Hyperdrive does this at the edge so workers can reach an origin Postgres or MySQL database quickly.
- I/O-bound vs. CPU-bound: I/O-bound work spends most of its time waiting on network or disk. CPU-bound work spends it computing. Workers are best for I/O-bound apps.
Learning Resources
If this episode has you curious about building Python web APIs for global, low-latency deployment, these courses are a good place to go deeper.
- Modern APIs with FastAPI and Python: FastAPI is the framework Cloudflare uses in its Python Workers examples, and this course teaches you to build realistic APIs with type hints, async and await, and Pydantic.
- Async Techniques and Examples in Python: Python Workers run on an asynchronous, event-loop-driven runtime without threads or subprocesses, so a solid understanding of async and await, asyncio, and the tradeoffs among concurrency models pays off right away.
- Python Web Apps that Fly with CDNs: Hood described Workers as a CDN that distributes programs instead of static files. This course covers the CDN fundamentals underneath that idea and how to use a global network to speed up your Python web apps.
Overall Takeaway
Python Workers being generally available is the result of years of unglamorous systems work by a small group of people: memory snapshots that replay malloc addresses, socket system calls that stack switch into a JavaScript event loop, CPU limits that interrupt Python without skipping finally blocks, and a packaging PEP that lets the whole PyPI ecosystem target WebAssembly. What you get is a simple deal for Python developers. Write the FastAPI, Django, or Flask code you already know, deploy plain Python files, and have it run near your users in more than 350 cities, often for free. It isn't the place for heavy numeric work, but for I/O-bound APIs and business logic it changes where Python can run. The story behind it is just as good. A mathematician who complained about bugs became a maintainer, an open source contributor got hired to keep building, and a project Mozilla stepped away from now runs Python across a global network. As Hood put it, WebAssembly still has plenty of open niches, and if something you want doesn't work yet, you can be the one to fix it.
Links from the show
Gyeongjae Choi: linkedin.com
Hood Chatham
Dominik Picheta
Pyodide: pyodide.com
Python Everywhere: The State of Python on WebAssembly - Hood Chatham, Gyeongjae Choi: www.youtube.com
PEP 783: peps.python.org
D1 Databases: www.cloudflare.com
Hyperdrive: www.cloudflare.com
R2 Object Storage: www.cloudflare.com
Queues: developers.cloudflare.com
AI: www.cloudflare.com
now generally available: blog.cloudflare.com
Memory Snapshots for CPython (Python Language Summit 2026\): blog.python.org
Cloudflare Worker Limits: developers.cloudflare.com
Litestream: litestream.io
workerd: github.com
Are we PEP 783 yet?: pyodide.github.io
The Birth & Death of JavaScript: www.destroyallsoftware.com
Watch this episode on YouTube: youtube.com
Episode #568 deep-dive: talkpython.fm/568
Episode transcripts: talkpython.fm
Theme Song: Developer Rap
🥁 Served in a Flask 🎸: talkpython.fm/flasksong
---== Don't be a stranger ==---
YouTube: youtube.com/@talkpython
Bluesky: @talkpython.fm
Mastodon: @talkpython@fosstodon.org
X.com: @talkpython
Michael on Bluesky: @mkennedy.codes
Michael on Mastodon: @mkennedy@fosstodon.org
Michael on X.com: @mkennedy
Episode Transcript
Collapse transcript
00:00 Where does your Python code actually run?
00:02 A server in Virginia?
00:03 A container in Frankfurt?
00:05 Pyodide put Python in the browser.
00:07 Cloudflare put the browser into the server.
00:10 Combine the two and you get Python workers, now generally available from Cloudflare.
00:15 My guests are Hood Chatham, Jay Choi, and Dominic Pichetta from Cloudflare.
00:20 Hood and Jay maintain Pyodide.
00:22 Dominic got Python running in Cloudflare workers.
00:25 Your FastAPI app ships as plain files.
00:28 Then you can run it on CPython, compiled to WebAssembly, inside V8, at over 350 locations worldwide.
00:36 This is Talk Python To Me, episode 568, recorded October 9th, 2026.
00:57 Welcome to Talk Python To Me, the number one Python podcast for developers and data scientists.
01:03 This is your host, Michael Kennedy.
01:04 I'm a PSF fellow who's been coding for over 25 years.
01:09 Let's connect on social media.
01:10 You'll find me and Talk Python on Mastodon, Bluesky, and X.
01:13 The social links are all in your show notes.
01:16 You can find over 10 years of past episodes at talkpython.fm.
01:20 And if you want to be part of the show, you can join our recording live streams.
01:23 That's right.
01:24 We live stream the raw, uncut version of each episode on YouTube.
01:28 Just visit talkpython.fm/youtube to see the schedule of upcoming events.
01:32 Be sure to subscribe there and press the bell so you'll get notified anytime we're recording.
01:37 Tomorrow, Wednesday, November 4th, we're having our first tech meetup, our live tech event as part of Talk Python membership.
01:44 If you're not yet a member, well, join up and support the show and get an awesome community and experience to boot.
01:51 Just visit talkpython.fm, click membership in the nav bar, and you'll be off to the races.
01:56 If you are a member, we'll be talking about Talk Python in production and some really wild new ideas that I'm exploring.
02:03 I think you will find both fascinating and actually really practical, but no one's doing it.
02:09 So join me on Wednesday, November 4th.
02:10 And if you're listening to this after and thinking, Michael, why did you just put this in here?
02:14 Nobody can listen to it because most people listen to after.
02:17 These tech meetups come with recordings.
02:19 Just visit talkpython.fm, click on membership, and then browse past member meetups and you'll be able to get it.
02:23 So hopefully either you can join live or you can join afterwards.
02:27 Become a member, support the show, join the event.
02:30 Dominic J.
02:31 Hood, welcome to all of you to Talk Python To Me.
02:34 Awesome to have you here.
02:35 Awesome to be here.
02:36 Yeah, I'm really excited to talk about Python on the Edge.
02:40 It's very exciting what you all have announced.
02:43 And I know it's been out there on Cloudflare for a little bit, but it's now officially formalized, officially supported,
02:50 a little more smooth.
02:51 So Python workers, very, very cool topic.
02:54 Before we get to that, though, let's just do a quick, who are you?
02:58 Just give me a little bit of your background and what you do and so on.
03:01 Dominic, we'll just go around the squares here.
03:02 Dominic, go first.
03:04 Sure.
03:05 I mean, I can get started how I got into Python.
03:08 And that starts at, I guess, a very young age when I was playing with Visual Basic.net.
03:13 And I realized that I hate Windows.
03:15 I needed to get to Linux and Visual Basic.net back then did not support Linux at all.
03:21 So a couple of my friends were using Python. So that's how I got into it.
03:26 Afterwards, I actually got a little bit annoyed that Python was interpreted.
03:30 So I looked for alternatives and I got involved in the NIMH programming language.
03:36 And I became one of the core developers of that for a while.
03:40 Fast forward a lot.
03:42 I was working at meta and then I moved to Cloudflare to work on the workers runtime team working there on a bunch of
03:51 features for workers in general.
03:54 I actually was the person I guess that kind of experimented with Pyodide at Cloudflare and got it working and running and then eventually we got Hoodin to
04:05 help us out with that and we started Python Workers and I've been working on that ever since as well
04:11 And still do.
04:12 Very, very excellent.
04:13 You know, a word I haven't thought about for a while is visualbasic.net.
04:17 I've written a little bit, a little bit.
04:19 I mean, we're talking a couple of files of visualbasic.net.
04:22 What of her boast language?
04:23 I don't know.
04:24 Great language to learn with, though.
04:25 It is, it is.
04:26 You know, I think it's interesting to contrast that with Python, actually,
04:29 because Python also had many of the same goals of VB, but it somehow accomplished it
04:35 with a lot less stuff on the screen.
04:38 You know, like there's not begin if, end if, all this type of stuff.
04:42 But yeah, very, very fun.
04:43 Jay, welcome.
04:44 Hey, I think I can start with how I started using Python as well, like Dominic.
04:48 So I also started programming using some Visual Basic NC when I was like 10 years ago.
04:55 And then I started learning Python when I was in second grade in university,
05:01 I think.
05:01 I was having some data science course learning about packages like ThumbPy and SciPy.
05:08 That was when I first started using Python.
05:10 And I just fell in love with Python.
05:12 Like making apps were so easy with Python.
05:15 So I was using, I started, starting then I started using Python for like 10 years.
05:20 And around 2021, I started contributing to a library called Pyodip, which I think we will talk a lot in this podcast.
05:32 And yeah, after maintaining it for around one or five years, I got invited to Cloudflare to work on Python workers using Pyrodite from Hoots and joined Cloudflare.
05:46 And yeah, after that, I was working on Cloudflare Python workers for around a year.
05:51 That's super cool that contributing to the project got you that position.
05:56 It's like, I'm really interested in this thing and I get to work on it for a while.
05:59 And all of a sudden they're like, well, what if we paid you to do it all the time?
06:02 That's just great, right?
06:04 Yeah, it's really interesting that you start to contribute on open source and you get a job with that.
06:10 That's something that all the open source contributors are hoping to.
06:15 Good. Welcome to the show.
06:16 I started out on Lispy MLE languages.
06:19 So I'm a mathematician by training.
06:23 I wrote my first Python code for undergraduate introduction to programming class.
06:29 but then I didn't use it at all until I had to write an email schedule for the math seminar
06:35 which was in Python 2.7 and I am as a mathematician I was very interested in
06:43 math software to try to get software that does a good combination of like research level
06:51 you know like high performance computing and also just like quick experiments and lets people
06:58 figures step out. And I found out that mathematicians don't like to install software
07:02 on their computer. They assume it won't work.
07:04 Of course, a lot of...
07:05 They still have scars from Fortran.
07:06 That's why, probably.
07:08 Yeah.
07:08 And also, a lot of math software is made by mathematicians and it's not an easy thing to
07:14 distribute software for other people to use.
07:16 And so it's like they have something that works on their computer and they tell all their friends, oh, you should use this. And they say, nah,
07:21 man.
07:22 So that was how I got interested in WebAssembly. I mean, I first started by writing software in
07:28 LaTeX because mathematicians already have LaTeX on their computer and they already have TechLive
07:32 on their computer.
07:33 And that's a package manager. It can just get your package onto their computer
07:36 automatically.
07:37 But like people just wouldn't use things that didn't come sort of connected with
07:41 something they already had on their computer.
07:43 And because browsers are a universal computing platform, you know, I watched the birth and death of JavaScript back in like 2014 or whatever.
07:51 One of the best talks ever.
07:52 So good.
07:53 Yeah, yeah, it's so good.
07:55 And so I was very excited about the idea of like, oh, we should just make the software work in WebAssembly
08:00 and ship it to the browser.
08:01 And then mathematicians won't be able to like complain that it's maybe takes some work to install.
08:08 But then if you want to have like, you know, powerful math software, you know,
08:12 I wrote all the linear algebra stuff in Rust, but then, you know, you don't really get that much control over it from Rust.
08:20 And you can make a GUI, you can give people JavaScript, But, you know, JavaScript is really a bit anemic in terms of, you know, like, for instance, our logic have lots of tables of things that were indexed by, you know, tuples of integers.
08:34 And like, you know, having a map in Python that is nicely indexed by tuples of integers is like,
08:40 you know, you could do it in JavaScript.
08:41 It's just it's just a pain.
08:42 So I really wanted to get Python to be in my web application with everything else.
08:47 And so I found out about Pyodine and I started messing around with it, but it was really buggy and didn't work very well.
08:53 you know, I mean, it was a sort of technical, you know, like demonstration.
08:57 I mean, it showed a lot of promise because, you know, there was NumPy there running in the browser.
09:03 So, you know, these binary extensions were working.
09:06 But, you know, Mike Dropeboom did like amazing work at Mozilla to get that working. And I mean, Mozilla really created this whole cool chain on top of it.
09:15 Anyways, I can maybe say more about that later.
09:18 But I found PyDyde and it was just a bit after mozilla killed the whole project so it wasn't you know um roman urchuk was like just barely keeping
09:26 the lights on and i showed up and i was like here are all the things that are bad about what's
09:29 currently going on it kind of expecting him to be like oh like you're an asshole go away but he was
09:35 like oh well why don't you come fix those things and so so i so he made me into a maintainer it
09:40 actually first took another math that i was working with on the same project uh dexter who who had some
09:46 experience with open source and so he started contributing to fix the problems that i found i
09:50 I was like, oh, I guess I can contribute to this.
09:53 Yeah.
09:53 That's a great way to handle somebody coming and say, I have these complaints.
09:56 It's like, instead of saying, go away, it's like, you know what?
10:00 Here's how you can fix them.
10:01 Yeah, right.
10:02 Yeah, very productive.
10:03 Right.
10:03 They weren't defensive at all.
10:04 They were just like, great, we want this to be better.
10:06 Like, if you want to make it better, please make it better.
10:09 And so then I got a National Science Foundation postdoc for math.
10:14 I said I would improve mathematical computing software.
10:16 And so I ended up spending most of that postdoc working on Pyodide.
10:20 And then when I was leaving the postdoc, I got hired to Anaconda to work on their PyScript stuff.
10:26 And then about six months later, I got connected to Cloudflare and they were interested in me working on making Python workers exist.
10:34 That was obviously a very fun project.
10:37 Yeah, PyScript is such an interesting project.
10:40 I don't know what the future holds for PyScript, but it's a very neat project.
10:44 Yeah, it was really an interesting project.
10:46 Actually, a lot of people first learned about running Python in the browser from PyScript,
10:51 not from Pyodide.
10:52 Yeah, it was a really interesting project.
10:54 It's very unfortunate they turned into a maintenance mode recently, but they did a real great job.
10:59 I know, it makes me sad.
11:02 Maybe it's just taking a break.
11:03 Maybe it'll come back in the future in some amazing form.
11:05 I would love to see a React or a Vue alternative that just runs all on PyScript.
11:12 But, you know, I don't think backed by Pyodide, backed by MicroPython, which would be,
11:17 you know, I think a little more practical for web front end.
11:19 But that is an alternate reality and a different thing that we're talking about.
11:22 So let's begin maybe just a quick review of like running in the browser.
11:29 So the goal of Pyodide is to run wherever WebAssembly runs.
11:33 Primarily, that's the browser, though it doesn't have to be.
11:35 You know, you can kind of treat WebAssembly a bit like a Docker type of thing, like an isolation.
11:39 You can use the JavaScript.
11:40 Right.
11:41 So it does not work in WASM time or these other WebAssembly only run times, but it should work in any JavaScript run.
11:47 I see. So I could run it locally if I had, say, Node or Bun or something like that, maybe?
11:52 Absolutely.
11:52 Yeah.
11:52 Okay. That's interesting.
11:54 So we have this WASM execution time, execution framework here.
11:59 And the idea you all had is like, well, we have all these points of presence throughout the world with Cloudflare.
12:06 How many places, how many spots does this run at? You all know.
12:10 oh i don't know by heart there's like a website you can go on and tells you the
12:16 all of them i think i think the number is above 350 yeah yeah it sounds like yeah so that puts
12:22 10 tends to a hundreds on any given continent right so the idea is with these these kind of
12:29 getting ahead of ourself a little bit but the idea is like well what if we could take this
12:32 pyodide thing that is a miniature python runtime and put it really really close to all the users
12:39 and execute it there instead of routing back, you know, somewhere in US East 1 or something like that, right?
12:45 Yeah, precisely.
12:46 I mean, you're giving the exact explanation that I think a lot of our, like, marketing people would give,
12:55 which is great.
12:56 Basically, yeah, like, you want as little latency as possible for your users,
13:01 right?
13:01 So you want to run Python code as close to them as possible, and this is a very great way to do that.
13:05 Yeah, and it doesn't run, to be clear, what we're talking about does not run in the browser of users like Pyodide can.
13:13 It runs in the edge nodes of Cloudflare that happen to be very near the users, right?
13:20 So I think that's a big difference because it gives you access to an entire platform
13:24 like data and queues and all that kind of stuff that we're going to talk about,
13:27 right?
13:28 The way I like to describe it is like Pyodide is kind of this crazy idea of like,
13:31 we should put Python into the browser.
13:33 And then Cloudflare is kind of this crazy idea of like, we should put the browser into the server.
13:38 and so when you put Python into the browser and you put the browser in the server,
13:41 that's a funny way of getting Python into the server.
13:43 Yeah, as a mathematician by the transitive property, you click it all together.
13:47 It sounds like a crazy idea though.
13:49 Yeah.
13:50 So let's talk PyDyde just for a minute before we dive in, now that people see where we're going with PyDyde.
13:55 Let's talk about it a little bit because very recently, let's put some, one month ago,
14:00 Hood and JU2 gave a talk at EuroPython, which I thought was really interesting.
14:05 Python Everywhere, the state of Python on WebAssembly.
14:08 So this is a more general, not just Cloudflare worker type of story, but give us an update.
14:15 What is the state of Python on WebAssembly?
14:17 Things are good.
14:20 It feels like there is less and less stuff that's going wrong.
14:27 So I have these Python enhancement proposals to try and rearrange the governance of our code
14:37 so that it can live maybe more of the stuff in the CPython repository.
14:44 But yeah, I mean, I remember just a few years ago that there were always like crazy problems
14:49 and lots of confusing bugs.
14:53 And it was like, yeah, like we got lots of bug reports that would just be like,
14:58 I have no idea what to do with this.
15:01 But it feels like we really polished it a lot.
15:04 And I mean, especially Jay moved all of the package build system into external repositories.
15:12 And so the package build system is much less causing us trouble, although it's still still causing us some residual trouble.
15:19 But now we have the PEP that says we can upload packages to PyPI.
15:23 So it really feels like it's kind of making this graceful landing and approaching something that, you know,
15:31 it will always take maintenance to keep up with upstream Python, but I'm sort of feeling like
15:36 it's taking less and less in addition to that, which is nice.
15:39 What's the situation or the state with Pyodide and Python on WebAssembly in terms of being officially supported by the core
15:47 developers of Python?
15:48 I feel like it's gotten some sort of build support acknowledgement before they
15:54 were willing to ship CPython that Python on WebAssembly also compiles. Is that right?
15:59 Yeah, so, right, so Python, sorry, so the platform we have is called Emscripten, right?
16:06 This is the Emscripten compiler tool chain, which is this incredible thing that is front end for Clang and ships.
16:14 JavaScript system calls JavaScript implementation of a file system.
16:18 It's like a JavaScript Musa Linux that Emscripten compiles to.
16:22 And so we have to recommend that people go back and watch the birth and death of JavaScript because it tells the story so well, right?
16:29 Yeah, it's one of the greatest videos ever, for sure.
16:32 And so, okay, so Emscripten is the platform, and Emscripten is tier three supported upstream by Python.
16:40 And what that means is that we, well, we run it in CI, and, you know, it's best effort,
16:48 you know, people are allowed to break it, and, like, I come back and fix it.
16:54 And it's not a release block, or they, in fact, do not make releases for Emscripten.
16:59 The reason they don't make releases for Emscripten is because they don't have really a version of like the OS module or for Emscripten.
17:09 So they can't really do IO very much.
17:14 They can't make requests.
17:16 You know, they can't do HTTP stuff.
17:18 They can't receive user input.
17:20 And so in my opinion, if we build these executables, but no one would want to use it as it is built upstream.
17:30 And so I have this proposal, which is PEP 818, which I just submitted a few days ago for review by the steering council,
17:36 which is supposed to rectify the situation and make it so that we can have basically useful inscriptive iPhone binaries.
17:48 Okay, so let me read the title of PEP for folks.
17:51 It's PEP 818, adding the core of the Pyodide foreign function interface to Python.
17:56 Is this a little bit like the ABI interface or CFFI, something like that?
18:00 It's a little bit like CFFI or C types.
18:05 You know, the package, the top level import is going to be JS types, which is following C types.
18:11 And yeah, like the point of it is to allow calling JavaScript functions from Python,
18:16 which is important because basically all functionality in a JavaScript runtime goes
18:21 through JavaScript, just like the way all functionality in Linux goes through C.
18:25 Okay, excellent.
18:26 And this is in draft, might be out next year, maybe?
18:29 So I just submitted it for consideration.
18:33 So hopefully in the next couple months, the steering council will make a decision on it.
18:40 But you also have, and this one is accepted, is this is a big deal, PEP783,
18:46 the Emscripten packaging.
18:48 I think packaging is having a big moment in the Python space.
18:52 We just have the very first packaging council, right?
18:55 That election that came out.
18:56 And you talked about Jay doing a bunch of work to get the build of the packages other
19:01 places.
19:02 I'm very excited about the packaging council because what they had before was not that functional.
19:08 Whereas the people on the packaging steering council, I think they're going to do a really good job.
19:12 Yeah, yeah, yeah.
19:12 One of the great people.
19:13 Jay, what are your thoughts on this whole packaging story?
19:16 It sounds like you did some work on it as well.
19:17 Yeah, there's a long history about supporting packages in Pyodide and Python in the browser.
19:24 And that 7.83, 7.83 unscrupulous packaging is really a lifesaver for us.
19:31 Because so from the beginning of the Pyodide, we wanted to support packages like NumPy or SciPy or MatBotlib,
19:39 all those scientific Python packages that needs to be cross-compiled to WebAssembly
19:43 because they have C codes.
19:46 So if the package only contains the Python code, we can just run it because there's nothing needs to compile.
19:52 They're all interpreted.
19:53 But if the package has a C or C++ or Rust code inside, they need to be compiled into a platform,
20:01 which is for us WebAssembly or MScripten.
20:03 So at the beginning and until 2025, we had to cross-compile and build all the packages
20:12 in Pyodide CI to run them inside Pyodide.
20:15 And I think last year we had around 300 packages that needs to be built in our repository.
20:22 And it took like three or four hours to build all those packages in our CI.
20:27 So even if you like make a little like one line change in Pyodide that needs to run CI for like three and four hours to build.
20:35 And it was very flacky because, well, you know, Python packaging system is running some like Python codes in real time
20:44 and it's very fragile.
20:46 So like CI was always breaking.
20:48 So we really hope to make things done in package themselves.
20:55 We don't want it to maintain all the packages ourselves.
20:59 So we want, for instance, NumPy to build Pyodide wheels themselves and SciPy too.
21:05 And so that was that PAP 783.
21:10 And we had one more years of discussions to make it accepted thanks to a lot of work by Hood.
21:18 And we also standardized a lot of our build system so that people can actually easily build their packages
21:26 into a PyPI scripting platform without setting up a lot of things in their machine.
21:31 They can actually just use a cibuildwheel to build PyMD builds in their CI.
21:36 They just need to add one PyMD platform and that's it.
21:38 They can build PyMDs and builds in their CI.
21:42 And that makes such a big difference, right?
21:44 Because if you all were trying to take everyone else's projects and build it, I can't even imagine.
21:49 I mean, it's one thing that's pure Python, but if it's C or Rust and it doesn't compile to WebAssembly correctly,
21:55 what do you do, you know?
21:57 Right, well, we have this horrifying compiler wrapper that rewrites the compiler arguments
22:02 to fix all the problems.
22:03 Right, we still have that.
22:05 We still have it, it's not going anywhere.
22:07 Cross compiling is still not easy, but it's all abstracted inside our build system.
22:12 I mean, people will still face some issues, but like most of the packages now just build,
22:17 which is awesome.
22:18 Yeah, this is one concern I have been going back and forth with Jay about is that there's still a lot of compiler regressions.
22:27 So like when we were doing the Python 3.15 update, you know, and I was trying to get up to the most
22:33 recent version of mscripten. And it was like, you know, I had to go up like 10 versions,
22:37 10 releases, and almost every single one of them had like some weird regression in it.
22:42 And that broke builds of some package.
22:45 And so what's really still the big difficulty for us is that we need to make sure
22:51 that we find these problems.
22:53 And then I can put fixes for them into our compiler tool chain, our tooling that says like,
22:59 oh, there's this weird bug in the compiler.
23:01 But if we edit the compiler arguments, or we rewrite something a little bit,
23:07 then it will go away and the users won't see it.
23:10 or we can go up to the compiler and say, like, you know, hey, like, let's patch this.
23:14 Or, you know, I mean, I'm a maintainer of Unscripted now, so I can, you know, help drive it
23:19 into a non-buggy direction.
23:21 But my concern is very much that we could specify an ABI and a platform and then not find out that it's broken
23:31 until downstream package maintainers start trying to use it.
23:35 And so that's the one sort of big issue that we need to figure out is like,
23:40 how do we make sure that we have confidence in our platform?
23:45 Which I think basically still means we have to carry builds for a bunch of packages
23:49 just to make sure that we cover like all the different weird things that different packages rely on.
23:54 Compilers have an amazing amount of surface area in terms of like what is expected
24:00 for them to behave like.
24:01 Dominic, were you going to jump in and say something?
24:03 Yeah, I was just going to say that I think the main thing that this packaging PEP
24:08 really brings is that it does actually enable packagers and maintainers of packages
24:13 to actually build for WebAssembly and for Pyodide, right?
24:17 And it's not really, like, it doesn't really scale for Pyodide to be doing all of that themselves.
24:24 So this is, like, really powerful to help spread the load and help all these, you know,
24:29 the long tail of packages work on Pyodide. So much. I had pulled up PyPI here, just as
24:35 I was going to just bring it up. We're coming up million packages it doesn't make sense for you all try to bring this in into it yourself so if it's
24:44 possible for whoever wants to be on mscripten and pyodide and so on to just do that by setting up
24:50 ci build wheel and setting a wheel they're basically like it's awesome right yeah yeah
24:55 off the cuff i think only about five percent of those packages have any uh c c plus plus or rust
25:00 in them so uh luckily most of them are pure python and don't yeah that's trying to track what which
25:06 packages have Python scripting wheels now. So there is a website called rwepap783yet,
25:13 which is created by another Pyodag maintainer.
25:15 And it's already a lot of packages have Python scripting wheels, and some of them we are still maintaining ourselves.
25:22 But it's, yeah, like, majority of the Python applications will depend on those top 500 Python packages.
25:30 So you're trying to support those packages.
25:32 Yeah, so you can look through and see all the popular ones and go, Okay,
25:35 yeah, this is great.
25:38 The yellow ones are those packages that are not supported yet.
25:42 And the green ones are those that have the fence wheels in PyPI.
25:47 And the blue ones are those we are still building ourselves.
25:51 Oh, interesting.
25:52 That's what the blue means.
25:52 Okay.
25:53 And then some of them are just none for their wheel designation because they're pure Python.
25:58 Setup tools is pure Python.
25:59 Right.
26:00 I guess it's probably worth pointing out that you all talked about this before,
26:03 but just because something's pure Python doesn't mean that it's going to work on Pyodide, right?
26:08 There's just parts that are missing because the runtime themselves are like,
26:12 yeah, your OS thing, no.
26:14 This comes from a browser or whatever, right?
26:16 Or your raw socket support, I don't know about you.
26:20 Yeah, right.
26:21 If the package is depending on some native things like threadings or multi-processing or self-processing,
26:28 and the native sockets will not basically work and browser Piodies.
26:33 If you're running in Cloudflare Workers or Node.js, they will work because Node.js have access
26:39 to some of them and still threadings or sub-processes are not working, but some of them will work
26:45 depending on the platform you're running in Piodies.
26:47 Does async.io work?
26:50 That was a big project when I first started maintaining Piodies was to make async.io work
26:55 because everything in a browser is async.
26:58 So when there wasn't a good asyncio story for Pyodide, it was like really rough to use it
27:04 because you had to just like.then, .then, you know.
27:06 Yeah, callback, callback, callback, right?
27:09 And, you know, at least in JavaScript, a lambda can have like, you know, a multi-line body.
27:14 And so like lambdas are not that bad in JavaScript, whereas in Python, like lambdas suck.
27:18 So you have to do like death, like a thing, and then put it, it's like.
27:21 I wonder if Python should have had multi-line lambdas.
27:25 I do kind of like them for.
27:27 I think it should have actually been.
27:28 and then it kind of went to line land.
27:31 I think curly braces are the way.
27:35 Oh, you're going to cause a fight.
27:37 The developers would disagree with that.
27:40 If I have curly braces, I can have multi-line lambdas that I care way more about.
27:44 You can have multi-line lambdas without curly braces as well.
27:48 But no one's ever figured out the syntax.
27:49 That's why it doesn't exist.
27:51 They have, actually. There are languages that do it.
27:54 Backslash.
27:55 Backslashes, come on.
27:56 It has to fit with the existing syntax of Python.
28:00 So if you designed a new language, you could maybe make it work.
28:03 I don't think we're going to be able to completely solve this curly braces are not problem.
28:09 But Hood, I expected parentheses from you as a Lisp person, just parentheses,
28:13 parentheses, parentheses, parentheses.
28:14 I'm looking with parentheses too.
28:17 I don't object.
28:18 Lisp also can have multi-line lab.
28:21 I can't do all the parentheses in Lisp.
28:23 It's not going to work for me.
28:24 What if you had new syntax?
28:26 I do think there's interesting new syntax that can be added.
28:29 We've got the no coalescing or non coalescing operators and that kind of stuff possibly coming to Python.
28:37 There will be things, but I don't think multi-line lambdas are going to be one of them.
28:40 All right, let's talk about, we talked about a little bit, but let's go ahead and just talk a bit about
28:45 edge workers in general.
28:47 Because we talked about you've got over 300 points of presence.
28:50 They're all near the users.
28:52 That totally makes sense.
28:53 but maybe compare and contrast this with like running on a VIP, just a virtual server or in Kubernetes or even serverless.
29:01 Because to me, it feels kind of serverless-like, but not.
29:04 I mean, it is serverless, I would say.
29:06 What makes you think it's not?
29:08 Well, a traditional serverless, I guess.
29:10 You're right, it is serverless.
29:11 I'm thinking like AWS Lambda and that kind of.
29:14 Yeah.
29:15 So in my mind, AWS Lambda runs in a data center.
29:19 Like my Lambdas are set to run in US East 1 or in Frankfurt or something like that.
29:24 And in that way, it's not the same.
29:25 I feel like these words like edge and serverless and cloud are all more like marketing terms
29:31 than like technical terms.
29:32 And so that leaves some vagueness about what exactly they mean.
29:35 Yeah, I would actually consider, I mean, workers in general to be more serverless than AWS Lambda.
29:42 I mean...
29:42 I do too.
29:43 I do too.
29:44 Yeah.
29:44 Just because you don't have to worry about where you're placing your workers.
29:50 They just show up wherever your users are, which is great.
29:52 I think they're more serverless than Lambda as well.
29:55 The only thing is that Lambda claimed the term serverless before, right?
30:01 And so I think it's worth a little bit of a compare and contrast.
30:04 So I'm a user I've written, or I'm a user I'm consuming in API, open up,
30:10 I don't know, React front-end app, and it says, I need to do my work. I want to do it close to you.
30:16 So what happens next? How do these things work? Well, you connect to your nearest point of presence.
30:22 That nearest point of presence has the worker's runtime running on it.
30:26 That worker's runtime has v8 on it, and v8 runs Pyodide in WebAssembly.
30:32 Yeah.
30:33 But as a developer, I don't make that choice, right? It's like a dynamic DNS choice that says,
30:38 I know you asked for, I don't know, worker.collectifair.com slash whatever,
30:43 but you actually get Southeast Asia in this location.
30:48 And that's just kind of the magic of CDNs, right?
30:50 Yeah.
30:51 Okay.
30:52 So let's talk this back up.
30:54 I always describe this as being like a CDN, except for instead of with static assets,
30:59 it distributes programs and then runs the programs on your data.
31:03 Yeah.
31:04 Okay.
31:04 So let's talk about a deployment.
31:07 Do I deploy my Python files?
31:09 Do I do a local build and get a WebAssembly thing that I upload to you?
31:13 How does that work?
31:14 You don't build any WebAssembly things yourself.
31:16 Like all the WebAssembly things are already pre-built.
31:19 So the deploying Python workers is basically you write some Python codes.
31:24 And you need to, if you're using some Python packages as dependencies, you need to install them through uv.
31:29 So uv has a support for like installing Python packages that are built for WebAssembly into your local files.
31:36 Of course, you cannot run it inside your local machine.
31:38 like you'll only have like a native Python interpreter, or you can use Pyodite to run it.
31:44 So basically, we like compress all those, your Python applications and packages
31:49 into a Cloudflare web server, and it's distributed around the world.
31:53 And the Cloudflare runtime will like download the application and run it inside Pyodite and Cloudflare runtime.
31:59 Yeah, awesome.
32:00 What's the local dev story?
32:01 Now, I hadn't really thought about that before, but I want to debug it, play with it.
32:05 Yeah, so...
32:06 I push it up to...
32:07 Yeah, go ahead.
32:07 Go ahead, Dominic.
32:08 Yeah, so I mean, part of the worker's runtime is open source as worker D,
32:14 if you want to look it up, it's on GitHub.
32:17 And you basically run that locally.
32:19 I mean, we have like a CLI that wraps it for you. So it's nice and easy called Wrangler.
32:26 But we're moving to CF now as well.
32:29 But basically, you just you just run it locally, you you edit the files of your worker,
32:36 they get reloaded automatically.
32:38 as you edit them, you just send requests locally and see what happens.
32:42 Okay.
32:42 Yeah, I'll be sure to link to the WorkerD project so people can download and install it.
32:46 I'm sure it's in your quick start, though, right?
32:48 Yeah.
32:48 I think the very cool part of the Cloud for Worker's runtime platform is that the WorkerD is open source.
32:54 So basically, you can run the same code in the same runtime in your local machine and the prods.
33:00 You can test everything that happens in prod in your local machine.
33:03 Interesting.
33:03 So this really is what runs on the edge when stuff happens, but you can just run it locally as well.
33:08 Yeah, exactly.
33:09 Yeah, I mean, that's pretty unique, right?
33:11 Because if I was doing Lambda or I was doing EKS or something like that,
33:16 it's not the same.
33:17 I can install a Kubernetes cluster and run pods and stuff, but that's not the same as running
33:22 in Amazon's Kubernetes service.
33:25 And this sounds like it kind of is, which is pretty interesting.
33:28 So let's talk about the platform a bit because this, I was a little bit unsure of,
33:33 or just don't have a ton of experience.
33:35 So it's one thing to run Python, on a point of presence and point sort of thing.
33:40 But databases, is the database got a little bit my data?
33:43 You know, I connect halfway around the world to Postgres and is that maybe not as good?
33:48 So there's a bunch of interesting things as well.
33:50 And so you all like numbering for your D1, R2 and so on.
33:56 But I have this crazy fascination with SQLite right now.
33:59 So this is especially interesting to me.
34:03 So let's talk about some of these building blocks that not just Python workers use, but all of them.
34:07 But at the same time, they're here for the Python workers now.
34:10 And so that's pretty interesting.
34:12 Who wants to introduce D1 to the world?
34:14 Dominic.
34:16 Sure.
34:16 I mean, I can give it a shot.
34:20 So I personally love SQLite.
34:23 And I've actually been writing web apps using it, just even before running on workers,
34:31 because it's so versatile.
34:32 It's so easy to set up.
34:33 You just load the library and save the database on your local file system.
34:41 And I think this is basically an extension of that.
34:43 I mean, you just get a local to your worker SQLite database.
34:49 You can write to it.
34:50 It gets replicated across the world for you.
34:53 So, you know, and it scales with your workers as well.
34:56 You don't have to worry about that at all.
34:58 It's pretty wild because you've got like 300 database nodes, which is pretty incredible.
35:03 And for people who don't know, they might think of SQLite as a toy.
35:06 It is extremely fast as a database.
35:10 So it's pretty interesting, I think.
35:12 Now, the one thing that seems tricky is somebody in Southeast Asia and somebody in London writes
35:18 to the database at the same time.
35:20 Now what?
35:22 Yeah, to be honest, I don't know the details of how that works.
35:25 But I think there is some mechanisms to make sure that it's all consistent and you can
35:32 make sure there's no conflicts there. Yeah. Yeah. Yeah.
35:35 So something I've been looking at lately is Lightstream actually been setting this up.
35:41 So Lightstream is really interesting because it works on SQLite and you set up the write ahead log, the wall in SQLite, it will basically
35:49 synchronize and stream that write ahead log off to somewhere else for backup and replication and so
35:55 on. So I'm wondering, my first thought is probably they're doing something with the write ahead log
36:00 and then merging, you know, synchronizing that and then merging, combining it or something like that.
36:05 I'm not totally sure, but this is my theory.
36:07 One of the great things about the design of Python workers is that we just consume these things.
36:11 We don't need to know how they work.
36:13 Yeah, exactly.
36:14 It's awesome.
36:15 All right, we got a couple more.
36:16 Hyperdrive.
36:16 So D1 is kind of SQLite Hyperdrive.
36:19 And this, I think, is new as part of your launch, right?
36:22 This is kind of like distributed Postgres, but that wasn't available before.
36:25 I don't know exactly, right?
36:27 Something like this?
36:28 Yeah, I think a hyperdrive is relatively new.
36:30 And, and it's kind, I think it's kind of the proxy, I think I can explain as a kind of proxy that there's like a truth of source,
36:39 related database like PostgreSQL, MySQL, Summary, and the Summary. And we have a lot of like
36:45 proxies in the edge that can basically like make your database connections a lot more faster,
36:51 like each there's like 350 hyperdrives that like maintains the connection pool with the original
36:56 database, like making the read and write a lot faster.
36:59 Right, right.
37:00 You can turn on caching to say, you know, this table doesn't change very often.
37:04 So if you've read that table over here, then just, you know, answer questions from it,
37:09 something like that.
37:10 It's awesome.
37:10 Yeah, I would just add to that.
37:13 It's worth noting that we talked a little bit about sockets before and socket support
37:18 in Piodide.
37:20 And that is actually what I think, Jay, you've been working on, right?
37:23 making sockets work on workers for Python.
37:27 And that is what makes Hyperdrive work.
37:30 Hyperdrive is built on these TCP sockets.
37:33 So without that, it wouldn't work.
37:35 Yeah, exactly.
37:36 Exactly.
37:36 So supporting Hyperdrive in Cloudflare Python workers and in Pyrodite was one of the main goals for us
37:43 before launching it at GA.
37:47 And Pyrodite did not have socket support because browsers never had that.
37:51 But to use the relational databases, you definitely need TCP connections and sockets.
37:58 So we wired up the Node.js socket APIs inside Pyodide.
38:05 So workers' runtime support Node.js socket APIs.
38:08 So they are actually wired up inside Pyodide.
38:11 So that by calling socket syscalls inside Pyodide actually calls a Node.js socket calls.
38:17 So that's how AverageRM works.
38:18 This is really crazy because the socket APIs in Node, of course, are all asynchronous,
38:25 but most of the socket system calls that you have in Linux are synchronous calls.
38:30 And so in order to handle the system call, the system call has to stack switch and let the JavaScript event loop turn so that it can get the IO completed and then it unstacks switches and returns to the...
38:51 Yeah, that's wild.
38:52 So this is all transparent to C code.
38:54 So if you have a C application that consumes libc APIs to handle sockets,
39:00 it just works.
39:01 Yeah, I was kind of wondering if somehow you could unify the event loop of Node and the event loop of asyncio and kind of make them all one thing.
39:11 So that's what we've done.
39:12 So we have our event loop in Python, which we use for PyTag, which we call WebLoop.
39:18 And it basically just subscribes to the browser event.
39:21 And this is essentially necessary for two reasons.
39:24 One is that all actual IO happen on the browser loop.
39:28 Like there is really no way, like if you can make your own like separate loop,
39:33 but like it can't do IO.
39:36 And while it's spinning the real IO, it's blocking the real event loop, which can't do the real IO.
39:42 Yeah.
39:42 And I said there were going to be two reasons, but I feel like that was both reasons.
39:47 Well, it sounds like an important one.
39:50 Okay.
39:50 So we also have R2, which is like S3-ish.
39:56 Exactly.
39:57 How is it different, though?
39:59 Well, I think it's like almost the same.
40:02 The name R2 actually comes from S3.
40:04 It's like a 1 minus S minus 1 and 3 minus 1.
40:08 I see.
40:08 Yeah, so RS and then 3, 2.
40:10 It's exactly the same.
40:11 I think the main thing with it is that there's no egress fees.
40:16 So it's cheaper.
40:17 No egress fees.
40:18 Okay, very interesting.
40:19 All right.
40:20 And you can use this.
40:21 Some of these things, I guess probably almost all of them, you can use regardless of whether you're using Cloudflare workers or not.
40:27 I could use R2 just because I want object storage.
40:31 Interesting.
40:31 I'm about to think more about that.
40:33 It's giving me ideas.
40:34 Okay.
40:35 And you've got queues, Cloudflare queues, and AI inference.
40:39 So these are all the...
40:40 I kind of wanted to go through these because these are the building blocks
40:43 or the platform pieces that are available to these new Python workers, right?
40:47 Yeah, you have a lot of building blocks.
40:50 inside Cloudflow.
40:51 Developer platform, we keep adding it every month.
40:54 So I'm not, to be honest, not following all those releases, but queues and AI and their workflows,
41:01 things like that.
41:02 But you can easily connect your workers with those new features and to build a full stack application.
41:09 If you need a queue, you can use queue.
41:10 If you want to run AI inference into Edge, you can use Worker's AI, which is awesome.
41:15 Yeah, that's super, super neat.
41:17 All right, let's go to the announcement.
41:18 And here it is.
41:19 September 21.
41:21 Took us a little bit to actually press record, but it's been a few weeks, not too long though.
41:25 This announcement by the three of you, Python web workers are now generally available.
41:30 Hooray!
41:31 That's awesome.
41:32 How long had they been in beta style availability before that?
41:37 Feels like since like spring of 2024.
41:39 So I started in October of 2023 and it took about six months to get a beta going
41:46 and then it took like over two years to make it generally available.
41:50 Wow.
41:51 So what was that work?
41:52 Like trying, for example, the IO loops and all the different, all the just the sockets that Jay worked on,
41:57 all these things that you need in place.
41:59 That's what like data science pyodied to full runtime pyodied work was.
42:05 I think the packaging story was actually a big thing.
42:07 I mean, when we started, we, so there was two parts to this.
42:13 One was trying to make sure that the cold starts are as fast as possible
42:17 and especially when we're using packages.
42:20 And when we started, we figured we'll just allow people to use certain built-in packages that Pyodite provides.
42:28 But we just realized that that isn't flexible enough and we just need to allow people to use
42:32 whatever packages they want, ideally.
42:34 So we basically switched away from that approach to building a UV-based tool called PyWrangler,
42:41 which lets you just install any package that you want and get it into your worker very easily.
42:47 And then there's the memory snapshots aspect of it, which I think we might get to later.
42:51 Oh, yeah.
42:51 Oh, yeah.
42:52 Memory snapshots were basically what I started working on as soon as I came to Cloudflare.
42:56 I spent like two months researching memory snapshots before I wrote like any code, made
43:01 any pull requests at all.
43:03 Interesting.
43:03 Okay.
43:04 And you just gave a presentation at the Python Language Summit, also at EuroPython a little
43:08 while ago, right?
43:09 Yeah, right.
43:10 So this was about the fact that there is an important difficulty that comes up with memory snapshots, which is that it introduces a difference between sort of startup time or like, you know,
43:25 sort of like top level execution and like your actual like runtime logic.
43:31 And the Python language does not have a distinction like this, right?
43:36 Like the Python runtime, when you start it up, it bootstraps itself.
43:40 And then it just starts evaling user code.
43:44 And whether it's top level user code or calling a function, it doesn't matter.
43:49 Like it just evals until it stops evaling.
43:52 And when it runs out of stuff to do, it shuts down.
43:54 Yeah, even things like import statements are really code execution, not just, you know,
43:59 linking or whatever.
44:00 It takes a bit to wrap your head around it.
44:02 It's just right.
44:04 Like the import statement is compiled into something.
44:07 And then like those op codes get like interpreted.
44:09 And that causes import lib to go look up files on disk, find the thing that it wants to import.
44:15 And then it like starts executing that file.
44:18 And so for memory snapshots, you know, we say like, okay, look, all of that top level stuff,
44:23 it's going to happen the same every time.
44:26 So it's very wasteful to keep doing it every time someone's deployed an application to the edge.
44:32 Like every single time it cold starts, it's going to execute exactly the same top level code and end up with exactly the same outcome.
44:40 And so we would really like to just save that work.
44:44 And this is actually very similar to the work that like optimizing Python compilers like PyPy and Grawl Python do,
44:52 because they also want to evaluate all that stuff at compile time.
44:57 This is like partial evaluation.
44:59 So it's a bit of a different technology than a memory snapshot.
45:01 But it has the same fundamental issue, which is that it needs to impose a model of like what is startup time,
45:08 what can be precompiled onto a language that doesn't have one.
45:12 Now, of course, you know, I think this is this is this talk is like a fun thing to think about.
45:18 But, you know, I mean, at least Thomas Vouders said that it was like a nonstarter.
45:23 And I think he is right that like, you know, it's sort of too late for the language to get something like this.
45:27 But I have friends that are working on on, you know, new programming languages.
45:31 My friend Antonio Cooney is trying to make this language called SPI, which stands for static Python,
45:37 which is supposed to be like a better R Python, which was used for PyPy.
45:41 And basically, the main idea in some sense of the language is to pre-bake a notion of
45:48 compile, to create a notion of compile time versus execution time, and then allow lots
45:54 of compile time evaluation of spy code so that it can perform that.
45:59 Yeah, the basic idea is something like you're going to load the interpreter,
46:02 it's going to load all the standard library, it's going to maybe read some of the files,
46:07 parse them, do the import processing.
46:10 And that never changes, right?
46:11 Well, maybe the import, because it depends if you run code or not.
46:13 But other than that, you theoretically could say, let's just see what happens.
46:18 And like a VM, just go, your memory's back.
46:21 Continue.
46:22 Yeah?
46:22 Right.
46:22 And of course, there's a lot of subtlety in there because we have, for instance,
46:27 if you import a dynamic library, it does all this relocations.
46:33 It allocates space for all the global variables that the dynamic library is going to define.
46:40 And then it relocates them all into that space.
46:42 And it, you know, relocates all the functions from the dynamic library.
46:46 And somehow you have to do some crazy magic with the dynamic loader.
46:50 Basically, like I have a loader patch that when it loads a dynamic library,
46:54 writes down the relocation base that it's putting the dynamic library at.
46:59 And then when I'm going to restore the memory snapshot, I have to make sure that it gets relocated to the same place.
47:04 So I patch the malloc so that it will, instead of actually doing a memory allocation,
47:10 it just looks, oh, in this context, I'm allocating memory for this dynamic library.
47:15 In the snapshot, we allocated it at this address, so we're going to play back that address.
47:20 And then all this crazy magic just sort of...
47:23 That sounds supremely complicated.
47:25 It's very...
47:26 It was a lot of fun.
47:27 It's really horrible.
47:29 All right, so let's go back to the announcement.
47:31 There's a couple of code samples and different types of things here.
47:35 So programming model is a little bit like writing an API, yeah?
47:39 Yeah, I think the major usage of workers runtime is writing an API server.
47:45 So we used Face the API a lot in our examples.
47:48 So a lot of Python users might use Python in different ways, but I think the major use case of workers runtime is to build an API server
47:57 and connecting different findings in it.
47:59 So yeah, that's the examples we show in our flow post.
48:02 Yeah, you want your API to be super snappy and responsive.
48:06 So if you could put your data in D1 and then have your code also run right literally in
48:12 the same process right there, like that's going to be really great.
48:15 Yeah.
48:15 So you can, if you know how to write a FastAPI app, it's the same thing.
48:19 Just instead of uvacoron.run, it's just hand off the app and off it goes,
48:24 which is really, really neat.
48:26 Now, the examples that I saw on this page, I don't remember, I'm pretty sure they all
48:30 have like one request, just like forward slash.
48:33 can I have a more complicated app with, say, five or six different endpoints?
48:38 Yeah, that's just per short, yes, right?
48:39 Like, you know, you could make any FastAPI app you want here, right?
48:43 Yeah, there is no limits to how many endpoints you can have.
48:47 I suppose it might be worth talking about the actual limits that the workers have.
48:51 And that is, yeah, so it's memory, which is 128 megabytes, and CPU time as well.
48:59 You know, I think actually a great thing about workers is that you can do quite a lot
49:03 free, like completely for free, you don't have to pay anything to Cloudflare,
49:06 you can run a very simple FastAPI application, even I think, for free.
49:11 What's the free request limit is like 100,000 requests a day?
49:15 Is that right?
49:15 Yeah, yeah, you get 100,000 requests, I think, per day.
49:20 And yeah, if you type in workers limits into Google, it should show up.
49:26 But if you know, if you're just doing kind of more CPU intensive stuff, then that is another limit that we have.
49:33 Yeah, it's basically there 10 milliseconds for free of CPU time and five minutes for paid.
49:39 But yeah, you can do quite a lot.
49:42 It's very, very flexible.
49:43 Right.
49:44 Speaking of what we were doing for those two years, another thing that took a lot of careful work was making sure that when you run out of that 10 milliseconds of
49:51 CPU time that a signal is delivered to the Python runtime, and it gracefully interrupts its
49:58 execution and returns to Cloudflare so that it doesn't like leave it in a broken state.
50:04 Because if you do this the naive way, JavaScript throws a non catchable exception into the runtime and
50:12 forcibly unwinds all of the call stack without executing finally blocks or,
50:17 you know, catch blocks.
50:18 And so like any locks that you've taken that you were expecting to release in a finally block,
50:22 that just doesn't get executed.
50:23 And then the runtime is like completely broken.
50:26 And so Or like half written files that are not, the buffer's not flushed. All
50:31 sorts of things could go wrong. All sorts of things, you know, like loss of code relies on finally blocks executing
50:36 and it was not executing the finally blocks. And so we had to like do some very elaborate thing to
50:42 make the CPU time limiter deliver the signal correctly to the Python M-scripted operating system inside of the
50:50 runtime.
50:50 Of course, we have the same problem with Rust workers.
50:52 So we basically have the same solution for both Python workers and for Rust workers for that.
50:57 As you start to bring in more languages, you're like, this is kind of the same problem.
51:01 Okay, this is great.
51:02 You've got a lot of computer.
51:05 100,000 requests a day for free?
51:07 That's a lot.
51:08 You can do a lot.
51:10 Many, many little hobby apps and small apps live well under that limit.
51:14 Right. I think the good part of for like hobby developers is we have really generous pricing.
51:20 I don't want to be too marketing pitch, but I also used Qualifier when I was a student
51:25 because they really offered a good free pricing.
51:28 Like you can have like 10 gigabytes of R2 for free, I guess.
51:31 So there's a storage, there's a runtime, there's everything you can use freely.
51:36 Yeah, well, and you know, the storage is one thing, but the egress, that's where you pay money often
51:41 for S3 is you pay tons of bandwidth charges.
51:45 Yeah, very neat.
51:46 All right, let's see.
51:47 Let's go back to this.
51:49 So first class language, really good.
51:52 FastAPI, Django, Flask.
51:55 Does it basically run anything that does WSGI or ASCII as each return that?
52:00 You know, like, of course, there could be problems with them trying to start threads and things like that.
52:04 But assuming that they don't try to start too many threads, then, like, you know, we have a general purpose ASCII
52:11 and WSGI adapters that you see here.
52:13 Okay.
52:14 Yeah, well, you know, that was one of the best things that happened to Python web,
52:16 right?
52:17 That you got this interface that you can plug into all these different runtimes.
52:21 And, you know, it sounds like you're as well.
52:23 It's amazing for us.
52:24 Yeah, because they don't try to do IO directly.
52:26 And so, you know, I mean, that's exactly the problem we have with something like URL of three.
52:30 Of course, URL of three specifically supports Pyodide.
52:32 So it's okay.
52:33 But like, it's normal way of doing IO just doesn't work.
52:36 So it needs a separate path for Pyodide.
52:40 And all of these things would need that if it weren't for these beautiful adapters.
52:44 that... Yeah, they're super polished and optimized.
52:47 It's really nice.
52:48 Yeah. Let's talk. We only got a couple minutes left before we're out of time.
52:52 It's late in some places, early in others.
52:56 Let's maybe round out this conversation by the types of apps that you see people building
53:02 in Cloudflare workers in general, and specifically also in Python.
53:06 Everyone knows what an API that talks to a database looks like, but can I
53:10 do data science work here?
53:11 Can I do long-running work? What types of things are people building here?
53:15 A lot of the workers that I've looked at are big piles of boring business logic.
53:20 It's just a mess, and it does apparently what they are needing.
53:25 I would not recommend data science.
53:28 It's not really a platform that has a lot of computing power.
53:33 If you want to do things like graphics cards, SIMD, it doesn't have any of that.
53:38 But it's a very powerful platform for stuff.
53:43 That's totally fair.
53:44 And I think that's one of the things I was trying to kind of explore is, right?
53:47 Like how far can you push it before it just starts timing out or whatever, it runs out of memory.
53:53 But what if I'm, let's say I'm a researcher or a student and I've got a pandas or just a parquet file
54:00 with 20,000 records.
54:01 And I do basic, like, here's a, let me do a little bit of query on that then I'll draw a graph or whatever.
54:06 It can, in principle, do stuff like that.
54:09 Yeah, that seems like it might work.
54:10 Right.
54:10 You can load pandas.
54:11 You can load, you know, whatever the parquet package that is popular now is.
54:18 And, you know, I mean, just the packages, you know, if you start, you know, like, for instance,
54:24 SciPy is just too big, too horrible.
54:28 And it doesn't really work to import SciPy.
54:32 I mean, SciFi, when you bring it in, it has like over 100 different shared libraries.
54:37 You know, yeah, SciFi has been like a real journey for us in Pyodide.
54:43 Like it's really like the most horrible package.
54:47 But if it's not SciFi, you know, Pandas works and you can just, you know, load your Parquet file and share your graph as long as it's not too big.
54:56 Well, in my opinion, like pandas or docdb or other data processing libraries are not very optimized for Python workers.
55:02 It's because like there are different, like the concept is a little bit different because workers is very memory limited environment.
55:09 So we basically recommend everything to run in streams, not like load a bunch of memory,
55:15 like lots of data frames inside memory.
55:17 More polars, less pandas type of flow, yeah?
55:20 Yeah, like, yeah, more polars, not pandas.
55:23 if you need to load all the data frames in your memory, that it won't fit.
55:27 You need to do streams.
55:28 But actually, like Python packages are, especially legacy Python packages,
55:32 are not very optimized for that.
55:33 So we'll need to do a lot of back and forth to make it work properly.
55:37 Right.
55:38 Yeah, I mean...
55:39 Go ahead.
55:39 You go.
55:40 So we're talking about Pyodide and WebAssembly.
55:44 Another way, if I was this theoretical person I was describing, wanted to put this stuff on workers,
55:49 maybe what I do is I just put my parquet file and my WebAssembly stuff on Cloudflare
55:54 and just put it on the front end, right?
55:56 You could run it like a JupyterLite style of execution.
55:59 And then everyone gets their own little browser runtime instead of Edgeware runtime.
56:03 Lots of people are doing exactly that.
56:06 And then of course, all of the compute is paid for by the end user.
56:10 Exactly.
56:11 That's your iPhone battery or your iPad battery or whatever, rather than your compute bill.
56:19 Because setting up that kind of stuff is really tricky for researchers who are not developers
56:23 and they're not DevOps people.
56:24 They're just like, I just want to share this thing, right?
56:27 So maybe that's the way to go.
56:29 All right.
56:29 I've talked to so many people who are doing that, like sharing their data science notebook,
56:34 like instead of having to have a Jupyter notebook and then they make it and then their collaborators
56:39 don't have the right things on their computer or it doesn't quite work.
56:43 You know, this is exactly the same sorts of problems I saw in math all the time.
56:46 And, you know, these internet-based tools are just like so great for them
56:51 You know, and it really is like what happens with like a math or science project is like if there's a lowest common denominator effect where like the technology you can use your research is only the things that the least technically competent person in your group can use.
57:07 Because if you can't get get it onto their computer and get it working for them,
57:10 then they won't be able to productively contribute to a project that needs it.
57:13 Yeah, yeah.
57:14 And you're looking over at your 67 year old thesis advisor who still thinks Fortran is like the hot stuff. And you're like, Oh,
57:22 gosh, some of these people literally like it's like they have they like dictate to their secretary and like they've never touched a computer. And some of these people like contribute to the Linux kernel like regularly.
57:33 Yeah, exactly.
57:34 They both look like a 67, like nerdy mathematician, but like, just like the farest ends of the scale of like confidence with computers.
57:43 Incredible.
57:44 All right, you guys, let's call it there.
57:46 There's a lot of stuff that we could talk about.
57:48 I guess one really, really quick thing I just want to give a shout out to is this memory snapshot stuff that we talked about.
57:53 Hood, you all are using that for basically increasing the startup time, the cold start time.
57:58 We want it.
57:59 We want it to go.
57:59 Sorry, you're right.
58:01 Increasing the speed, decreasing the time.
58:04 Yes, I blended those together and that doesn't work.
58:06 So just that's part of the mix, right?
58:09 That's absolutely right.
58:10 It's to not do that startup stuff again.
58:13 Yeah, awesome.
58:14 All right, final thought.
58:15 I'll give you all a chance to give a quick shout out to listeners who are like,
58:19 huh, this is interesting.
58:21 What do I do now?
58:22 Dominic, you're first.
58:24 Well, I was just going to say, actually, I think the best thing for workers is IO-bound applications.
58:31 if you have something that's like pushing a lot of bytes, isn't doing a lot of CPU with them,
58:36 then give it a try.
58:38 I think you'll be surprised how far you can go how many users you can handle
58:41 even on the free tier.
58:43 And yeah, just check it out type in Python workers into Google and give it a
58:47 try.
58:48 Well, yeah, I also say just give it a try.
58:51 Because I'm already running a lot of my hobby applications in Python workers.
58:55 It's working really well.
58:57 So please go give it a try.
59:00 If let us know in our Discord and we'll exit.
59:03 And I just want to advertise to anyone out there that WebAssembly is like a really cool ecosystem.
59:09 There's a lot of missing pieces in terms of like fundamental computing.
59:12 So if you like operating systems, if you want to think about like how LibC works
59:18 or, you know, low level details, and, you know, you feel like Linux works too well
59:25 for you to get into, then like I think WebAssembly is a really great space
59:28 because a lot more of that stuff is just I think no one has ever even tried to make it work.
59:33 There's not that much effort.
59:35 The total number of people working on it is quite small.
59:37 So there's lots of open niches.
59:39 And if you find something that you wish worked that doesn't work, you can just sort of wedge yourself in there and fix things.
59:45 So I think it's a great space.
59:47 Excellent.
59:48 All right.
59:48 Thank you all for being on the show.
59:49 I learned a lot.
59:50 I didn't point out at the beginning, I should have, that I'm a complete newbie at all this edge worker stuff.
59:55 So it was really interesting to get a look into it.
59:58 And it's awesome to see it come into the Python space.
01:00:00 See you all later.
01:00:01 Thank you.
01:00:02 Thank you.
01:00:04 This has been another episode of Talk Python To Me.
01:00:07 Thank you to our sponsors.
01:00:07 Be sure to check out what they're offering.
01:00:09 It really helps support the show.
01:00:11 Tomorrow, Wednesday, November 4th, we're having our first tech meetup, our live tech event as part of Talk Python membership.
01:00:19 If you're not yet a member, well, join up and support the show and get an awesome community and experience to boot.
01:00:26 Just visit talkpython.fm, Click membership in the nav bar and you'll be off to the races.
01:00:31 If you are a member, we'll be talking about Talk Python in production and some really wild new ideas that I'm exploring.
01:00:38 I think you will find both fascinating and actually really practical, but no one's doing it.
01:00:43 So join me on Wednesday, November 4th.
01:00:44 And if you're listening to this after and thinking, Michael, why did you just put this in here?
01:00:48 Nobody can listen to it because most people listen to after.
01:00:51 These tech meetups come with recordings.
01:00:53 Just visit talkpython.fm, click on membership, and then browse past member meetups and you'll be able to get it.
01:00:58 So hopefully either you can join live or you can join afterwards.
01:01:01 Become a member, support the show, join the event.
01:01:04 If you or your team needs to learn Python, we have over 270 hours of beginner and advanced courses
01:01:10 on topics ranging from complete beginners to async code, Flask, Django, HTMX, and even LLMs.
01:01:16 Best of all, there's no subscription in sight.
01:01:19 Browse the catalog at talkpython.fm.
01:01:22 And if you're not already subscribed to the show on your favorite podcast player,
01:01:25 what are you waiting for?
01:01:27 just search for Python in your podcast player.
01:01:29 We should be right at the top.
01:01:30 If you enjoyed that geeky rap song, you can download the full track.
01:01:33 The link is actually in your podcast player share notes.
01:01:36 This is your host, Michael Kennedy.
01:01:38 Thank you so much for listening.
01:01:39 I really appreciate it.
01:01:40 I'll see you next time.
01:01:52 I'm out.


