Pyscript powered by MicroPython
On this episode, we dive into some news that might change that calculus. The MicroPython and PyScript folks have been teaming up to get PyScript running in the browser on MicroPython. Yes, that's the embedded chip Python. Here's the good news: MicroPython's WebAssembly is just 300k to download and loads in under 100ms. Now that could unlock some possibilities.
We have Brett Cannon, Nicholas Tollervey, and Fabio Pliger on the show to discuss.
Episode Deep Dive
Guests Introduction and Background
- Brett Cannon: A Python core developer for nearly two decades and currently the dev manager responsible for Python in VS Code at Microsoft. He also serves on the Python Steering Council, helping guide the future of the language.
- Fabio Pliger: Creator of PyScript and the current tech lead for the PyScript project at Anaconda. He’s deeply involved in the Python community and has extensive experience working on tools that bring Python to broader audiences.
- Nicholas Tollervey: A principal engineer on the PyScript team at Anaconda. Nicholas has a varied background as a classically trained musician, teacher, and Pythonista, and he previously worked on the BBC micro:bit project, showcasing his passion for education and micro-hardware programming.
What to Know If You're New to Python
Before diving into running Python in the browser or learning about MicroPython and WebAssembly, here are a few quick points to help you get ready:
- You only need to understand basic Python syntax: Variables, loops, and functions are enough to follow most of the discussion on how Python can run beyond a typical server or desktop environment.
- Knowing that Python is both an ecosystem (with libraries and frameworks) and a language will help you see why we can have multiple Python “runtimes” (CPython, MicroPython, etc.).
- If you want to get started writing Python code from the ground up, check out the beginner resources below.
Key Points and Takeaways
- The Promise of PyScript + MicroPython PyScript burst onto the scene as a way to run Python in the browser with minimal friction. By combining MicroPython (a super-lightweight Python implementation) compiled to WebAssembly, PyScript can start in under 100 milliseconds and load as little as ~300 KB—comparable to a hero image on many websites. This drastically improves the practicality of Python-in-the-browser for interactive demos and web-based educational tools.
- Links / Tools:
- Why WebAssembly Matters WebAssembly (Wasm) allows low-level languages (traditionally C/C++ or Rust) to run at near-native speeds in modern browsers. Python can be compiled to Wasm using tools like Emscripten, bridging the gap between Python’s flexible syntax and the browser’s security and sandboxing model. Although still maturing, Wasm opens up huge possibilities for deploying Python apps client-side without lengthy server round trips.
- Links / Tools:
- MicroPython’s Embedded Edge Originally developed by Damien George for small microcontrollers, MicroPython is optimized to run in as little as 16KB of RAM. Its incredibly small footprint and fast startup make it a natural fit for WebAssembly, especially on devices like phones or when minimal download size is critical. It does not include the full standard library—just enough to remain “Pythonic” while staying lightweight.
- Links / Tools:
- PyScript as a “Platform,” Not a Framework PyScript aims to be the foundation for creating Python-based web applications without forcing developers into a single framework style. This platform approach means that you can plug in different runtimes (Pyodide for heavier data science, MicroPython for instant loading) and possibly build additional tools or frameworks on top of it. The PyScript team specifically architected it to allow the community to shape its future through plugins and add-ons.
- Links / Tools:
- DOM and JS Interoperability One of the biggest tasks in bringing Python to the browser is ensuring it can talk to JavaScript and the DOM. PyScript wants to enable Python code to respond to user events, manipulate web elements, and trigger visual updates, similar to any JavaScript application. Progress has been made (and continues) toward bridging that gap, so you can, for example, hook a Python function to a button click or update dynamic charts with pure Python.
- Links / Tools:
- Education and the Next Generation of Python Users Chromebooks, mobile devices, and browser-based programming environments are increasingly prevalent in classrooms. Python in the browser—especially with a fast-loading interpreter—offers an easy on-ramp for students without setup hassles. Simply load a web page, and you’re coding in Python. This can spark creativity by letting learners quickly see the results of their code.
- Links / Tools:
- Different Flavors of Python for Different Use Cases CPython is considered the reference implementation with a comprehensive standard library, while MicroPython strips down the standard library significantly. PyPy, Brython, and others add to the diversity. This variety exists because Python is both a language specification and a community ecosystem of runtimes—each with unique strengths or trade-offs.
- CPython 3.11 Speedups and Beyond Python 3.11 has made significant speed gains, which encourages people to write more pure Python code rather than dropping into C or Rust. This benefits WebAssembly builds too, because pure Python modules often “just work” once the runtime is compiled. The ongoing “Faster CPython” initiative hints that performance gains will continue in future releases.
- Links / Tools:
- Node.js and Server-Side WebAssembly While the episode focuses largely on browser-based Wasm, there is also interest in running Python runtimes on Node.js. This opens up the potential for using MicroPython or CPython in places traditionally occupied by JavaScript—like GitHub Actions or other server scenarios. The lesson is that Wasm is not just for front-end apps; it can unify the entire stack.
- Links / Tools:
- VS Code’s Web Editor Python Support Brett Cannon’s team at Microsoft is adding features for Python within VS Code.dev, an entirely browser-based version of Visual Studio Code. They have enabled real Python execution (via WebAssembly) and are working on debugging support. This underscores the momentum behind Python on the web, illustrating that even local dev environments can become optional.
- Links / Tools:
Interesting Quotes and Stories
- Nicholas on Education: “There’s nothing more intimidating than a class of 30 teenagers on a Friday afternoon. Print hello world doesn’t cut it. But if they can open a web page on a phone and start coding Python, that’s a big win.”
- Fabio on PyScript Vision: “We’re in creative or experimentation mode right now where we can try stuff, maybe it’s not the ‘correct’ way for some, but it can work for 90% of use cases. That’s where breakthroughs happen.”
Key Definitions and Terms
- WebAssembly (Wasm): A low-level, assembly-like language that runs in the browser at near-native speed.
- MicroPython: A lightweight implementation of Python designed for microcontrollers and constrained environments.
- CPython: The standard, reference implementation of Python, written in C.
- PyScript: A platform that embeds Python in the browser by leveraging WebAssembly-based runtimes, providing a development experience similar to native JavaScript.
Learning Resources
If you want to strengthen your Python skills for these exciting front-end or embedded adventures, here are a few courses from Talk Python that might help you go deeper.
- Python for Absolute Beginners: Learn the fundamentals of Python step by step.
- Anvil: Web Apps with Nothing but Python: Discover how to build full-stack web apps using only Python.
Overall Takeaway
The conversation reveals how Python’s ecosystem is expanding beyond its traditional boundaries, especially through WebAssembly and lightweight runtimes like MicroPython. This opens new horizons for education, lightweight front-end apps, and cross-platform development. While there are still technical hurdles and performance trade-offs, the energy behind projects like PyScript makes browser-based Python closer to reality than ever before. These innovations—together with Python’s growing speed and flexibility—highlight just how vibrant and future-facing the Python community remains.
Links from the show
Brett Cannon: @brettcannon@fosstodon.org
Nicholas Tollervey: @ntoll@mastodon.social
Fabio Pliger: @b_smoke
Michael Kennedy: @mkennedy@fosstodon.org
Web Assembly: developer.mozilla.org
pyodide: pyodide.org
micropython: micropython.org
Picture of TFT ESP32 Board: pythonbytes.fm
pyscript: pyscript.net
Simon Willison's Post About micropython + pyscript: fedi.simonwillison.net
WASI: github.com
Watch this episode on YouTube: youtube.com
Episode transcripts: talkpython.fm
--- Stay in touch with us ---
Subscribe to Talk Python on YouTube: youtube.com
Talk Python on Bluesky: @talkpython.fm at bsky.app
Talk Python on Mastodon: talkpython
Michael on Bluesky: @mkennedy.codes at bsky.app
Michael on Mastodon: mkennedy