Skip to content

Playground

This page runs the real wayfault library — the exact same Python wheel you pip install — directly in your browser. No rewrite, no server, no API.

How can Python run in the browser? (the porting question)

The library is not re-implemented in JavaScript. Instead it runs on Pyodide, which is CPython (plus numpy, scipy, …) compiled to WebAssembly. The page:

  1. loads the Pyodide runtime from a CDN,
  2. micropip-installs the published wayfault wheel (wayfault-*-py3-none-any.whl) — a pure-Python wheel, so it just works,
  3. calls estimate_wwr(...) and hands the resulting numbers to a JS chart library (Chart.js) for rendering.

Because wayfault's only hard dependency is numpy (which Pyodide ships natively) and the optional extras are lazily imported, the whole library drops into the browser unchanged. This is the recommended way to "port" a numpy-based Python library to the web: don't port it — run it on WebAssembly.

Initializing…