Cloudflare adapts its Workers platform to Python

Infrastructure and DNS service provider Cloudflare announces an expansion of programming options for its serverless platform Cloudflare Workers. In addition to JavaScript, TypeScript or Rust, developers can now also use Python directly to program new workers – thanks to the integration of Pyodide into the Workers Runtime workerd. Cloudflare has officially released the new Python Workers as an open beta version.

Advertisement

In order to ensure comprehensive support for Python right from the start, the Cloudflare development team has decided to integrate the programming language directly into the Workers platform – eliminating the need to compile to WebAssembly or JavaScript. The choice fell on Pyodide, a port of CPython to WebAssembly (Emscripten), which runs directly in the web browser and supports most of the Python standard library. With Pyodide you can also use many popular packages such as regex, pyyaml, numpy and pandas, as well as others from the Python Package Index (PyPI).

Cloudflare has integrated Pyodide into the open source runtime workerd, so that bindings – including to other Cloudflare applications such as Vectorize, Workers AI, R2 or Durable Objects – are immediately available. Packages can be imported without additional build steps or tools. The Foreign Function Interface (FFI) in Pyodide allows developers to call JavaScript APIs directly from Python. When programming new workers, the same range of functions is available as with JavaScript.

The Cloudflare team sees another advantage of Pyodide in the fact that both the interpreter and all native Python modules can be built as separate WebAssembly modules and dynamically linked at runtime. Workers running on a machine can then use the same code from the modules instead of having to bring their own copy of it. This particularly pays off in environments with thousands of workers.

More details on integrating Python into the Workers platform can be found on the Cloudflare blog. Anyone who would like to find out more about this or get actively involved should take a look at the discussions on GitHub.


(map)

To home page

source site