Bridge
speed up Python with Rust via WebAssembly - Oct 2020
Install / Use
/learn @savarin/BridgeREADME
bridge
Simple examples for Python-Rust interop via WebAssembly.
Commands
To run microbenchmarks:
python run.py
To install wasmtime with pip:
pip install wasmtime
To recompile microbenchmarks.wasm:
rustup target add wasm32-wasi
rustc lib.rs --codegen opt-level=3 --crate-type=cdylib --target=wasm32-wasi
Context
Foreign function interfaces (FFI) allow programs written in one programming
language to call routines in another language. This can be done through dynamic
libraries i.e. .dylib/.so/.dll files for Mac/Linux/Windows respectively,
as discussed in the post here
re: using Python to call Rust.
WebAssembly is a way of taking code written in programming languages other than
JavaScript and running that code in the browser; this effectively means the
compiled .wasm binary is agnostic to the choice of processor and OS. Lin Clark
has an excellent intro series on WebAssembly here.
The WebAssembly project has expanded beyond the browser, with wasmtime
as the independent runtime and WASI as the unified systems
interface. This could potentially make the .wasm format the new standard in
portable binaries for cross-language bridges.
The example in this repo calculates in pure Python and in Python with Rust via WebAssembly (1) the 10,000th prime number, (2) pi, and (3) the 25th Fibonacci number, with local microbenchmarks as follows:

Minimal examples to compile and run WebAssembly can be found here.
Related Skills
himalaya
343.3kCLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).
node-connect
343.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
claude-opus-4-5-migration
92.1kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
frontend-design
92.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
