~/talk

How to run Python in the browser

Talkat linux.conf.au 2022 · 2022-01-14..01-16· [webassembly, python]
slides:none on file

Compiles CPython to WebAssembly (using pyodide) and runs it in a worker thread so the UI stays responsive, connects stdout/stderr to xterm.js, and implements blocking stdin by sharing memory with SharedArrayBuffer and Atomics plus postMessage. Result is a real CPython REPL and filesystem (Emscripten in‑memory / optional IndexedDB) that works in the browser; download size is ~7.4 MB (WASM ~3.4 MB) and performance is roughly 2–3× slower than native CPython, with cross‑origin isolation required for shared buffers.

AI-written summary · about

  1. 0:00Start
  2. 19:47Two problems 1. Freezing the UI 2. Blocking on stdin
  3. 23:03Normally, reading from stdin is a blocking system call
  4. 32:16Browser support for SharedArrayBuffer/Atomics
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.