Python

Pyodide: Run Python in the Browser with WebAssembly

Pyodide brings the CPython interpreter to the browser via WebAssembly, enabling full Python scientific computing stack with zero server dependencies.

Keeping this site alive takes effort — your support means everything.
無程式碼也能輕鬆打造專業LINE官方帳號!一鍵導入模板,讓AI助你行銷加分! 無程式碼也能輕鬆打造專業LINE官方帳號!一鍵導入模板,讓AI助你行銷加分!
Pyodide: Run Python in the Browser with WebAssembly

What if you could run Python in the browser with full access to NumPy, pandas, scikit-learn, and matplotlib, without any server backend? That is exactly what Pyodide delivers. It ports CPython to WebAssembly, making the full Python scientific computing stack available directly in the browser.

Pyodide is a transformative technology for data science education, interactive documentation, and browser-based computation. Users can analyze data, train models, and visualize results entirely client-side. No servers to provision, no Python runtime to install, and no data leaves the user’s computer.

What Pyodide Includes

PackageDescriptionVersion Bundled
NumPyNumerical computingLatest stable
pandasData analysisLatest stable
scikit-learnMachine learningLatest stable
matplotlibData visualizationLatest stable
scipyScientific computingLatest stable

Architecture Overview

Pyodide runs a full CPython interpreter compiled to WebAssembly. Python packages with C extensions are compiled to WASM and linked dynamically. The JavaScript bridge allows seamless data exchange between Python and JavaScript, enabling Python code to manipulate the DOM directly.

Performance Characteristics

MetricNative PythonBrowser Python (Pyodide)
NumPy 10M ops0.15s0.35s
pandas DataFrame load0.5s1.2s
Python loop speed1x0.5x
Memory overhead~50MB~80MB base
Startup timeInstant1-3s initial load

For more information, visit the Pyodide GitHub repository and the Pyodide documentation.

Frequently Asked Questions

Q: Can Pyodide access the network? A: Yes, through the browser’s fetch API, bridged to Python’s requests-style API.

Q: Does Pyodide work offline after the initial load? A: Yes, once loaded and packages are cached via service workers, it works completely offline.

Q: Can I install custom Python packages? A: Yes, through micropip for pure Python packages or by building custom Pyodide packages with C extensions.

Q: How large is the Pyodide download? A: The base runtime is about 12MB compressed. Each additional package adds 1-10MB.

Q: Is Pyodide suitable for production applications? A: Yes, it is used by major platforms including JupyterLite, Google Colab’s client-side mode, and numerous interactive documentation sites.

TAG
CATEGORIES