Learn Python with Talk Python's 270 hours of courses

Say Hello to PyScript (WebAssembly Python)

Episode #367, published Wed, May 25, 2022, recorded Thu, May 12, 2022

Despite Python being overwhelmingly popular and positive, there are major areas of computing where Python is not present. Most notably on mobile and on the frontend side of the web. PyScript, a new project launched by Fabio Pliger from Anaconda, just might change that. It was made public and announced at PyCon just two weeks ago by Peter Wang and now has over 10,000 GitHub stars. But what is hype vs. reality vs. projected hopes and dreams? We're going to find out on this episode. Fabio is here to tell us all about his new project.

Watch this episode on YouTube
Play on YouTube
Watch the live stream version

Episode Deep Dive

Guests Introduction and Background

Fabio Pliger is a seasoned Python developer who has been deeply involved with the Python community for many years. He’s a core developer at Anaconda and has worked on notable data-focused projects such as Bokeh. Fabio has helped organize several Python conferences, including PyCon Italy and EuroPython, and he’s now spearheading the PyScript project, aiming to bring Python natively into the browser.

What to Know If You’re New to Python

Here are a few essentials to help you get the most out of this PyScript-focused conversation:

  • Understand the basics of Python’s syntax and its ecosystem (e.g., common libraries, virtual environments).
  • Know that Python can interact with JavaScript in the browser through special runtimes (like PyScript’s integration with Pyodide).
  • Familiarize yourself with the idea of using Python for front-end or web-related tasks—this can be very different from traditional server-side or scripting uses.
  • Be aware that PyScript is in early development, so things may change quickly.

Key Points and Takeaways

  1. PyScript’s Ambition: Python in the Browser PyScript is a framework that enables you to run Python code directly in the browser, leveraging WebAssembly and Pyodide. It’s designed to lower the barrier to building web applications by minimizing configuration steps and letting you keep everything in a single HTML page.

  2. Powered by Pyodide and WebAssembly Under the hood, PyScript relies on Pyodide, a port of CPython compiled to WebAssembly. This means true Python (rather than a partial port) can run client-side without server calls for computation. It supports many packages, including NumPy and other scientific libraries.

  3. Interactive Front-end Possibilities With PyScript, developers can add <py-script> tags, run Python code, and even mix in UI elements, animations, or data visualizations. Python code can call JavaScript functionality and vice versa, opening the door for highly interactive Python-driven UIs.

    • Links and tools:
  4. Where PyScript Shines While pure HTML pages typically don’t need Python in the browser, more interactive dashboards, data experiments, or educational apps can really benefit. By offloading compute to the user’s browser, developers can reduce server costs and infrastructure overhead.

  5. Performance and Loading Times WebAssembly-based apps often load a ~3–5MB runtime, which can feel large for minimal demos. However, once cached, subsequent loads are faster. For more substantial apps (think Jupyter-like or offline data science tools), the upfront cost is acceptable.

    • Tools:
      • JupyterLite (another Pyodide-based approach)
      • Browser caching & bundling techniques
  6. Data and File Handling in the Browser PyScript provides ways to load external Python modules or data files right inside HTML via <py-env> and the MicroPip system. While it’s still evolving, developers can fetch remote files, parse CSVs, or handle local storage using browser APIs without needing a traditional server.

    • Tools:
      • MicroPip for installing packages
      • Fetch API for browser-based file access
  7. Integration with the Broader Python Ecosystem Projects like Bokeh, Jupyter, and many others have proven that Python can be an excellent environment for interactive, data-centric tasks. PyScript extends this idea to the browser itself, hoping to unify Python’s web presence with minimal setup.

  8. Collaboration with CPython and Future of PyScript The PyScript team, together with Pyodide and CPython core developers, is working to minimize fragmentation. As CPython gets more robust WebAssembly support, PyScript will continue improving performance, packaging, and the interactive development experience.

  9. Use Cases: Education, Visual Demos, Offline Computing From teaching Python with a simple <py-script> block to building offline-friendly data analysis apps, PyScript can help avoid server complexities. Everyone from educators to data scientists can quickly prototype or share Python-based applications via a single HTML file.

    • Tools & resources:
      • Anaconda (Fabio’s organization background)
      • Example: “Anti-gravity” floating comic demo from the conversation
  10. Community and Open-Source Development PyScript is open source, welcoming contributors to improve documentation, add new features, or refine its APIs. Fabio emphasizes that stable versions and best practices will come from communal feedback and real-world usage, so early adopters are encouraged to share.

Interesting Quotes and Stories

  • Fabio on the Python Community: “You come for the language, you stay for the community. That is really my experience.”
  • On PyScript’s Potential: “We can view the browser as a mini-VM, and Python can live entirely there—no server round trips needed.”

Key Definitions and Terms

  • WebAssembly (WASM): A low-level binary instruction format for a stack-based virtual machine—enabling near-native speed for languages like C, C++, and Python compiled to run in the browser.
  • Pyodide: A WebAssembly port of CPython enabling many popular Python packages in the browser.
  • MicroPip: A lightweight “pip-like” tool for installing pure Python wheels and packages in a Pyodide-based environment.

Learning Resources

If you want to go deeper into Python and some of the concepts from this episode, here are a few courses:

Overall Takeaway

PyScript represents a fresh opportunity for Pythonistas to build interactive, browser-based applications without having to switch languages or rely exclusively on traditional web frameworks. By running Python securely and efficiently in the browser via WebAssembly, it unlocks new frontiers in education, data visualization, and beyond—all while harnessing the vibrancy of the Python ecosystem.

Links from the show

Fabio on Twitter: @b_smoke
PyScript: pyscript.net
Birth and Death of Javascript: destroyallsoftware.com
Power On: The Story of Xbox: xbox.com
PyScript source: github.com
JupyterLite: jupyterlite.readthedocs.io
Compiling CPython for WebAssembly: python.org
Space WebGL Demo: pyscript.net/examples
Antigravity Demo: pyscript.net/examples
D3 Demo: pyscript.net/examples
Most examples: pyscript.net/examples

Michael's pyscript PWA YouTube video: youtube.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

Talk Python's Mastodon Michael Kennedy's Mastodon