simonw 11 hours ago

I've been looking forward to this for ages!

This means we can now take any C/Rust/whatever extension for Python, compile that as a `.wasm` extension, and then load it directly in browser Pyodide projects using:

  await micropip.install("package-on-pypi")
  import package_name
Here's how to try the new feature out. Visit https://pyodide.org/en/stable/console.html and type:

  import micropip
  await micropip.install("pydantic_core")
  import pydantic_core
That gets you this WASM wheel: https://pypi.org/project/pydantic_core/#pydantic_core-2.47.0...

You can tell that it's got compiled code in (and not just Python) by running:

  pydantic_core._pydantic_core
I get this:

  <module 'pydantic_core._pydantic_core' from '/lib/python3.14/site-packages/pydantic_core/_pydantic_core.cpython-314-wasm32-emscripten.so'>
  • simonw 10 hours ago

    I had an older experimental Pyodide WASM project lying around (a packaging of the Luau language by Roblox) so I had Codex package that up for me and pushed it to PyPI.

    Here's the package: https://pypi.org/project/luau-wasm/

      import micropip
      await micropip.install("luau-wasm")
      import luau_wasm
      print(luau_wasm.execute(r'''
      local animals = {"fox", "owl", "frog", "rabbit"}
      table.sort(animals, function(a, b) return #a < #b end)
      for i, name in animals do print(i .. ". " .. name .. " (" .. #name .. ")") end
      '''))
    
    And an interactive demo page where you can try it out: https://simonw.github.io/luau-wasm/

    Wrote about this in more detail on my blog: https://simonwillison.net/2026/Jun/13/publishing-wasm-wheels...

  • willXare 9 hours ago

    `await micropip.install()` is starting to feel dangerously close to "just ship the whole universe to the browser."

  • rtpg 6 hours ago

    Is there any form of client-side caching that kicks in with all of this flow?

    Tbh I don't feel great about people just writing up a bunch of scripts pulling things just on every run.

    • simonw 6 hours ago

      Browser caching works with stuff pulled from PyPI, so it shouldn't get loaded more than once.

njoyablpnting 5 hours ago

Pyodide is great. I teach coding to kids, mostly creating 2d games with Python, and it was always a pain to manage an environment for each student. Now I have a browser based environment that runs Pygame/Arcade/Pyglet in Pyodide, so the kids can just do everything in the browser, I don't have to worry about Python versions, OS differences, files, etc. As a bonus they can easily publish what they make since it all runs in browser.

They haven't made anything too crazy, but performance is surprisingly good, even wiring in Pymunk for some physics stuff. If they get to the point where it's ever an issue they probably know enough to be working in a real game engine anyway.

12_throw_away 11 hours ago

Executing normal python programs inside a cpython vm inside a wasm context inside a javascript process inside a sandbox inside a browser is - genuinely - extremely exciting! (Might as well run the browser inside a container inside a VM while you're at it though.)

  • willXare 9 hours ago

    We heard you like runtimes, so we put a runtime in your runtime inside your runtime.

  • rvz 10 hours ago

    This sounds like a solution looking for an unnecessary security nightmare.

    Something as little as the runtime can just get exploited (which that as happened.) and cause a sandbox escape on the client side. There was a Chrome 0day at the runtime level which allowed untrusted code to run and escape the sandbox in the WASM runtime.

    This complete worship of WASM (and their runtimes) as this magical silver bullet reminds me of the days and failures of Native Client (NaCL), Java Applets and Flash all over again.

zek 7 hours ago

I've been working on a server-side wasm impl of cpython called boomslang [1] and have been thinking a lot lately about packaging, one of the downsides of my current impl is the need to statically link all c/rust extensions. Its too bad IMO how much of the wasm ecosystem targets/depends on emscripten directly. It'd be interesting to see if a more generic ABI could be provided for non emscripten/js based wasm runtimes.

[1] https://github.com/HubSpot/boomslang

  • posborne 34 minutes ago

    The WASI support in CPython has moved along very well and it is an early target via componentize-py[1]. Notes on WASI support in Python can be found in PEP 816[2]; CPython will be jumping from 0.1 to 0.3 (0.2 is adapted in componentize-py) which should unlock a fair bit of support, especially once cooperative threads lands (providing a pthreads impl in wasi-libc).

    [1] https://github.com/bytecodealliance/componentize-py [2] https://peps.python.org/pep-0816/

  • tancop 2 hours ago

    wasi 0.3 just came out and its fully component model based with no emscripten specific parts. also supports dynamic linking in the spec but afaik no runtime actually has it implemented in a released version.

  • DarkUranium 6 hours ago

    I think one of the issues is that WASM is notoriously hard to generate code for because they decided to use an IR that's fundamentally incompatible with literally any existing native compiler backend's IR (not counting very specialized ones or toy direct-ast-to-machine-code compilers).

    It feels like nobody actually consulted actual compiler writers when designing this. I'm sure that isn't true, but it definitely feels that way. (I suspect the truth is that they were consulted, but ignored.)

    It means codegen needs to resort to all sorts of hacks (like the relooper) in order to target WASM, a property not shared by any other target.

    And apparently, the way they handle variables also results in deoptimization, though I don't recall the details of that.

    Add the fact that interacting with the browser on the web still has to go via JavaScript to this day (for the most part, at least), and, well.

    ---

    TL;DR a combination of poor IR design that has a massive impedance mismatch with pre-existing compilers (and most new ones, because it turns out there's a reason the WASM approach isn't standard) plus WASM still being a second-class citizen in its supposed primary environment (the 'W' in WASM) --- the former ensures targeting it consumes a lot of resources/time, the latter ensures the bar for that to be worth it is much higher.

    You can target most architectures with little trouble (at least a a baseline --- optimization's a hard problem regardless of target, except maybe SPIR-V due to the recommendation that pre-optimization is limited in scope). But WASM is completely out there, it's closer to trying to target e.g. Java (not JVM!) at the backend instead of machine code or some other IR.

    You don't make an IR intended to be targeted by existing/native compilers by making it completely different to anything they had to target before and completely different to their own IRs and representations ... unless you're the guys behind WASM.

    • ameliaquining 6 hours ago

      I don't think the controversy about Wasm's structured control flow has anything to do with any of this? It's not actually difficult to target Wasm in codegen; I've never heard of any real-world compiler project complaining that this was a major burden. ABI concerns are at a different level.

      Most low-level IRs don't do structured control flow because most low-level IRs don't need to be translatable to verified-safe machine code in a single fast pass, whereas for WebAssembly that's a core design requirement.

      • csande17 4 hours ago

        http://troubles.md/posts/why-do-we-need-the-relooper-algorit... has a more detailed version of this argument: if WebAssembly had used a CFG as the basis for its control flow, it would have been easier to compile to and easier to efficiently execute/translate while maintaining safety, and maybe GCC would have released a WebAssembly backend by now.

        The author alleges that the real reason WebAssembly uses loop/block is because that's how V8 worked internally at the time and Google didn't want to go to the trouble of implementing something different. But more recently V8 has started moving towards CFGs ( https://v8.dev/blog/leaving-the-sea-of-nodes ) so maybe there's hope in the future.

    • hmry 6 hours ago

      From what I remember, it was specifically chosen (among other reasons) because of experience with the JVM, where it was difficult to verify bytecode type-safety due to unrestricted jumps and branches.

      So the choice was made to put the burden of regularizing the control flow on the compilers at compile time, rather than the browser engine at website load time. Which seems rational to me.

willXare 9 hours ago

Python in the browser keeps sounding ridiculous right up until it works.

wolfgangK 11 hours ago

I presume this works (will work) also for JupyterLite that is based on Pyodide ? Would be great if it helped getting the latest OpenCV-python version [0] and it's dnn goodies being available on a zero-install client side Notebook !

[0] https://news.ycombinator.com/item?id=48421858

  • simonw 11 hours ago

    Yeah it should definitely work there, anything you can `micropip.install()` into a Pyodide environment will work with JupyterLite.

fzumstein 11 hours ago

Pyodide 314.0 is already available in xlwings Lite (the Python in Excel alternative you actually wanted).

shevy-java 37 minutes ago

> You might be wondering: wasn’t the last version 0.29, and now it’s 314.0?

Now Python's versioning scheme is officially worse than PHP's or Perl's. Not just skipping one version here - they are skipping 314 versions!

efromvt 8 hours ago

Fantastic to have PyO3/Maturin guides too - the rust/python/typescript turducken I’ve always wanted.

runningmike 12 hours ago

Great news. And indeed a nice step to an even broader Python ecosystem.

sgammon 11 hours ago

nice to see JS/python interop becoming a thing