#wasm-interface #run-time #python #web #browser #layer #pyodide


WASM runtime compatibility interface implementation for the webbrowser WebAssembly runtime, exposed through Pyodide

7 releases

0.3.1 May 13, 2024
0.3.0 May 11, 2024
0.2.2 Apr 8, 2024
0.2.1 Mar 14, 2024
0.1.1 Mar 14, 2024

#179 in WebAssembly

Download history 141/week @ 2024-02-26 245/week @ 2024-03-04 301/week @ 2024-03-11 115/week @ 2024-03-18 4/week @ 2024-03-25 23/week @ 2024-04-01 113/week @ 2024-04-08 10/week @ 2024-04-15 12/week @ 2024-04-22 2/week @ 2024-04-29 173/week @ 2024-05-06 170/week @ 2024-05-13 30/week @ 2024-05-20 29/week @ 2024-05-27 26/week @ 2024-06-03

277 downloads per month


1.5K SLoC

CI Status MSRV Latest Version Rust Doc Crate Rust Doc Main


pyodide-webassembly-runtime-layer implements the wasm_runtime_layer backend API to provide access to the web browser's WebAssembly runtime using Pyodide.

The implementation of this crate is heavily inspired by the js_wasm_runtime_layer backend for the wasm_runtime_layer. Instead of relying on the js-sys and wasm-bindgen crates to generate JavaScript-based bindings to the WebAssembly JavaScript API, this crate uses Pyodide's js FFI layer to interact with WebAssembly through Python running inside WebAssembly. pyodide-webassembly-runtime-layer is therefore useful when developing a Python module in Rust, e.g. using PyO3, which requires access to some WebAssembly runtime using the wasm_runtime_layer API and may be deployed to the web itself using Pyodide.

Memory Management

pyodide-webassembly-runtime-layer generally tries to keep memory management intuitive by relying primarily on Python's reference counting to drop objects once they are no longer needed by both the user-written Rust code and the WebAssembly runtime. As this crate coordinates interop across Rust, Python, and JavaScript, it takes extra care to avoid reference cycles across the different memory management strategies of the languages which would otherwise lead to memory leakage. If using this crate produces a memory leak that is avoided with a different wasm_runtime_layer backend, please report it as a bug.

There is one exception to the intuitive memory management strategy:

  • Func::new creates a host function, which may capture arbitrary data. To avoid cross-language reference cycles, it is stored using wobbly references inside the Func and its associated Store. Even though the host function and its data are dropped once either the Store is dropped or references to the Func are dropped, additional bookkeeping data is required until both have been dropped.


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


pyodide-webassembly-runtime-layer has been developed as part of ESiWACE3, the third phase of the Centre of Excellence in Simulation of Weather and Climate in Europe.

Funded by the European Union. This work has received funding from the European High Performance Computing Joint Undertaking (JU) under grant agreement No 101093054.


~155K SLoC