Hacker News

tosh
Pyodide: a Python distribution based on WebAssembly github.com

simonw15 hours ago

Pyodide is one of the hidden gems of the Python ecosystem. It's SO good at what it does, and it's nearly 8 years old now so it's pretty mature.

I love using Pyodide to build web UIs for trying out new Python libraries. Here's one I built a few weeks ago to exercise my pure-Python SQLite AST parser, for example: https://tools.simonwillison.net/sqlite-ast

It's also pretty easy[1] to get C or Rust libraries that have Python bindings compiled to a WebAssembly wheel that Pyodide can then load.

Here's a bit of a nutty example - the new Monty Python-like sandbox library (written in Rust) compiled to WASM and then loaded in Pyodide in the browser: https://simonw.github.io/research/monty-wasm-pyodide/pyodide...

[1] OK, Claude Code knows how to do it.

VagabundoP11 hours ago

The who python web feels underused to be honest.

Maybe if browsers start shipping or downloading WASMs for python and others on request. And storing them for all sites going forward. Similar to how uv does it for for venvs it creates, there are standalone python version blobs.

bnchrch4 hours ago

At the same time it feels like the python is overused.

If I could wave a magic wand to reset any programming language adoption at this point I would choose Python over Javascript.

I think Pythons execution model, deep OO behaviour, and extremely weak guarantees have done a lot of damage to the soundness and performance of the technology world.

LtWorf13 minutes ago

python at least won't cast numbers to strings when adding them.

limagnolia3 hours ago

What do you mean by "extremely weak guarantees"?

joezydeco4 hours ago

Could you share the UI repo? This is really interesting stuff.

hashtag-til3 hours ago

joezydeco3 hours ago

Thanks!

iamcreasy14 hours ago

How do you call those C/Rust libraries compiled from to webassembly from Python/Pyodide?

simonw14 hours ago

You have to turn them into WebAssembly wheels, then you can import them as if they were regular Python modules.

wiseowise6 hours ago

Serious question: why would you use Python on the web? Unless you have some legacy code that you want to reuse. Performance is somehow worse than CPython, C-extensions are missing, dev experience is atrocious.

infamia2 hours ago

The web is the only major platform that has a language monoculture to its detriment (i.e., not all problems are Javascript shaped). IMO the web ought to become multilingual (and become JS optional_ to further ensure its continued longevity and agility. Hopefully one day browser vendors will offer multiple runtime downloads (or something similar capability).

wiseowise12 minutes ago

> i.e., not all problems are Javascript shaped

I’m having trouble coming up with a single Python-shaped problem that can’t be contained within JavaScript-shaped ecosystem.

simonw5 hours ago

C extensions aren't missing, the key ones are available in Pyodide already and you can compile others to WASM wheels if you need them.

You use Python on the web because there's existing software written in Python that you want to run in a browser.

b89kim3 hours ago

[dead]

screamingninja6 hours ago

https://marimo.app/

A reactive notebook for Python that runs in browser, powered by Pyodide. I have been using it extensively for teaching Python to non-STEM students that do not need the added friction of navigating the CLI or filesystem hierarchy.

akshayka5 hours ago

Hello from the original creator of marimo. Do you have teaching materials to share? I would love to see how one might teach Python with a reactive notebook

luke-stanley3 hours ago

Hey akshayka, I'm not that teacher, but I am a fan, and I notice that marimo sharing would be easier if export and import from normal boring Spyder/Jupyter percent formatted .py files worked by default, instead of indented `@app.cell` decorated functions, and same for for plain Markdown, where right now it has "{.python.marimo}" code blocks with triple backticks, that would normally just say Python. Import and export that used more normal metadata (like comments) would be amazing and would make pointing people to marimo easier. Any chance of this?

screamingninja4 hours ago

sending you an email!

fzumstein13 hours ago

Pyodide powers xlwings Lite, a free Excel add-in that you can install from Excel’s add-in store with a single click. It outperforms Microsoft’s official Python in Excel solution in every coceivable way: price, privacy, speed, can install packages, can access the internet, can access local files, doesn’t have a usage quota, can automate Excel and create native UDFs. See https://lite.xlwings.org

strujillo32 minutes ago

It’s impressive how mature Pyodide has become — running Python scientific tools in the browser opens up a lot of possibilities.

I’ve been working on a small (~800-line) Python system that uses sparse regression to discover physical laws from raw data. It was able to estimate the Sun’s rotation (~25.1 days vs 27 days actual) and found a temperature ~ velocity^3.40 relationship in solar wind data.

Having this kind of lightweight stack in the browser could make exploratory science much more accessible.

devsda15 hours ago

There's also xeus-cpp which is cpp based on wasm. Xeus-cpp and pyodide are the backends for Jupyterlite [1] kernels in browser.

It's actually a very good way to teach coding in python/c++(11, 17 or even 23), explore language features or your own library within browser and allow students to execute code by hosting just some static html pages and some assets without any backend.

1. https://jupyter.org/try-jupyter/lab/

QuadmasterXLII15 hours ago

It works surprisingly well in terms of writing python for native execution, and then trying to share on the web and having it Just Work TM. Unfortunately, when I want python it's because I want numpy, scipy and friends, and once you bring them on board pyodide load times are long. As an example comparison: a face turning octahedron puzzle in python + pyodide, loads in 10 seconds https://cubes.hgreer.com/fto.html . Meanwhile, a megaminx puzzle in javascript (statically generated by python) loads in 200 ms https://cubes.hgreer.com/ssg/output.html

ndran hour ago

related self plug: I built https://codeglf.com on Pyodide, a weekly Python code golf site where every submission runs locally in the browser.

WebAssembly's isolation means you get sandboxing for free without any server infrastructure. Of course users could cheat and submit code that doesn't actually pass the tests, but so far everybody has been friendly and I haven't needed to validate results server-side. Hopefully sharing the link here doesn't make that worse!

mcintyre19946 hours ago

Love all the tools mentioned in the comments, Pyodide is a fun tool. I built https://pyground.vercel.app with it a few years ago, as a quick way to run Python on a CSV/JSON file locally in the browser. For a while Python/Matplotlib was what I was most comfortable writing quick and simple analysis scripts with, and this was my go to for one-off data analysis work. You can drag-drop a file in, then some 'clever' code makes it available as `data` in the Python script so you don't have to write any parsing code yourself.

Now I'd probably just get Claude Code to write something locally, but there might be some value in a version of pyground that can use an LLM to write the Python code for you (and give it the data shape) but keeps the local execution setup the same.

ianberdin14 hours ago

Yea, I even built online ide based on Pyodide. Insane peace of software. You can try here: playcode.io/python

williamstein12 hours ago

I tried to make a version of this using Zig once, but ran out of steam: https://cowasm.org/

shevy-java12 hours ago

Everyone runs out of steam when it comes to WebAssembly. I used to wonder in the past why we hear so little about it, until I realised that nobody is really using it. Granted, there are those who use WebAssembly, but if we compare it to HTML, CSS, JavaScript, then WebAssembly is simply not existing anywhere near that level. After soon-to-be 10 years, that is very disappointing.

circuit106 hours ago

Why does it make sense to compare it to HTML, CSS and JavaScript?

You could say "Granted, there are those who use the webcam capture API, but if we compare it to HTML, CSS, JavaScript, then the webcam capture API is simply not existing anywhere near that level."

Like how not every website needs to use a webcam, not every website needs to port existing code to the web or accelerate heavy computation, which is what WASM is meant for... that doesn't mean it's not useful for ones that do. It's not supposed to replace any of HTML/CSS/JS

wiseowise6 hours ago

Because at the time of WebAssembly announcement all the doomsayers were screaming at the top of their lungs: "JS/TS are dead! Serious developer would never choose it! Finally I can have my <x> in the browser!"

circuit104 hours ago

That isn’t (currently) a goal of WebAssembly:

https://webassembly.org/docs/faq/

“Is WebAssembly trying to replace JavaScript?

No! WebAssembly is designed to be a complement to, not replacement of, JavaScript. While WebAssembly will, over time, allow many languages to be compiled to the Web, JavaScript has an incredible amount of momentum and will remain the single, privileged (as described above) dynamic language of the Web.”

wiseowise13 minutes ago

Good luck convincing JS haters.

IshKebab12 hours ago

Plenty of people are using Webassembly. Many more will use it once GC is properly supported and you don't need a JavaScript shim layer.

jasiek13 hours ago

I've used it to put together a browser app to program walkie-talkies: https://codeplug.org

yawnxyz16 hours ago

no but it works great in conjunction with observable and d3js for pretty interactives!

walterlw11 hours ago

could you please point to an example? For my project i'm currently animating matplotlib plots and walk through the video later, but rendering times are quite painful.

yjftsjthsd-h13 hours ago

That is very cool. Has anyone made a nice beginner's learning environment out of it? Seems like it would solve some of the extra friction that makes it hard to get started.

cfu2813 hours ago

I played around with it to build a little "intro to python" walkthrough on my blog a while back. It worked surprisingly well! I had a little trouble giving users the ability to ctrl-c if they accidentally wrote an infinite loop though lol (piodide supports it I just didn't implement it): https://cfu288.com/blog/2024-05_cwc-intro-to-python/

wisty13 hours ago

Jupyterlite - a lot of jupyter trial versions use it.

jacob01916 hours ago

Anyone using it with nodejs to make a sandbox for code agents?

simonw15 hours ago

I've done some experiments along those lines with Pyodide in Deno: https://til.simonwillison.net/deno/pyodide-sandbox

benjamincburns8 hours ago

Yes. More than a few times. It however is not really designed to operate as a secure sandbox environment.

https://nvd.nist.gov/vuln/detail/CVE-2025-68668

https://nvd.nist.gov/vuln/detail/CVE-2025-51464

https://nvd.nist.gov/vuln/detail/CVE-2026-25905

b89kim15 hours ago

ChatGPT's Canvas uses Pyodide for sandboxing, but it's not designed for coding agents. Node.js environment is usually better for agents. Pyodide restricts server-side functionality, and fetching external URLs often needs proxying due to sandbox. By the way, pyodide is still good option for interactive visualizer or deploying small webapps require data processing.

jcheng16 hours ago

For that purpose I think most people are using bubblewrap or seatbelt/sandbox-exec with CPython.

westurner12 hours ago

From https://news.ycombinator.com/item?id=47171887 re: [agent] sandboxing :

pydantic/monty, vercel-labs/just-bash, amla sandbox, csl-core, microsandbox, workerd, wasmtime-mte

containers/bubblewrap: https://github.com/containers/bubblewrap#sandboxing

The bubblewrap readme mentions containers as binaries with binctr; I guess without overlayfs or other file-level re-deduplication due to the container fs in the binary.

Perhaps similarly, also TIL UKI are easier for UEFI Secure Boot to check signatures on than (kernel, initrd) pairs

Archit3ch5 hours ago

Hoping for a Julia version.

ipunchghosts5 hours ago

REMUS RLF reader runs pyodide to parse underwater drone mission files in the browser

https://isaacgerg.github.io/remus-rlf-reader/webapp/

stainlu2 hours ago

[dead]

AgentMarket5 hours ago

[dead]

ldsjunior6 hours ago

[dead]

anarhackist16 hours ago

[dead]

shevy-java12 hours ago

WebAssembly will reach a breakthrough in the same year as GNU Hurd will dominate, together with the Desktop-Linux-of-the-year.

sts1539 hours ago

This is not funny. Sure, i have a technology that is a little bit slow, but i can run it nearly everywhere. Almost every day, there come a new desktop, OS, etc... but very soon a runtime for webassembly. It is good for that, what i call little data quick fixes.

hn-front (c) 2024 voximity
source