Pyo3 wasm sample code?

Short: Does anyone have sample code for pyo3 working in wasm ?


  1. shows Python running in browser in wasm.

  2. Rust can target wasm32-unknown-unknown.

  3. Does anyone have proof of concept using pyo3 (compiled to wasm) with python (running in browser in wasm).

Insights on why this might be difficult (say, dl open) would also be appreciated.


To clarify: both the python interpreter and the rust compiled code would be running in wasm in browser.

I don't think anyone has done this yet, There's so many moving parts that it'd be quite a build system challenge. Yes, lack of dynamic linking is going to make things more difficult, but there's no theoretical reason a rust module compiled with PyO3 couldn't be statically linked into the python interpreter, however it's painful.

Not exactly the same but RustPython might come in useful if your goal is to script a rust application that compiles to webassembly in python, there is even an online demo

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.