Skip to content

PyScript and Pyodide Recipes

This site contains a number of code snippets and guideines for accomplishing specific tasks with PyScript, Pyodide, and Micropython.

What are Pyodide, PyScript,and Micropython?

PyScript is an HTML-focused framework for utilizing WebAssembly-based Python runtimes in the browser. It adds additonal Python and HTML API's to ease integration of Python with web development.

Pyodide is a distribution of Python for Web Browsers and NodeJS. It takes the CPython interpreter, compiles it to Web Assembly (using Emscripten), adds some additional useful JavaScript APIs and Python APIs, and makes it all available via a CDN. Additionally, the Pyodide project provides over 100 packages with their C/Rust/Fortran extensions pre-compiled to run on WebAssembly; these are made available through an additional built-in tool called Micropip.

Micropython is a reimplementation of Python, originally intended for microcontrollers, that emphasizes small code side and rapid execution. Its download size is less than 5% of that of Pyodide/CPython, however due to its different object model, it is not generally compatible with CPython packages that have extensions in C, Rust, FORTRAN, etc.

What is a recipe?

A recipe is short snippet of code intended to do one simple thing. It is different from an example, which might be a fully-realized page accomplishing some holistic task; and a tutorial, which gives an in-depth explanation of the full usage of a specific piece of functionality or API.

Some recipes are followed by tutorials explaning how they work.