A WebAssembly interpreter by pure Python. WASM version: WebAssembly Core Specification W3C Working Draft, 4 September 2018
- py-wasmi has been tested and is known to run on Linux/Ubuntu, macOS and Windows(10). It will likely work fine on most OS.
- Python3.6 or newer.
$ git clone https://github.com/mohanson/py-wasmi
$ cd py-wasmi && python3 main.py # Run quick test
OR
$ pip3 install wasmi # The version may be outdate.
py-wasmi is dead simple to use. Write some c code belows:
int add(int a, int b) {
return a + b;
}
Generate add.wasm
by WasmFiddle, and then:
import wasmi
path = './tests/data/add.wasm'
with open(path, 'rb') as f:
mod = wasmi.Mod.from_reader(f)
vm = wasmi.Vm(mod)
r = vm.exec('add', [40, 2])
print(r) # 42
- How is the py-wasm performance?
Why care about performance on Python?