pyw

pywasm

A WebAssembly interpreter written in pure Python

Showing:

Popularity

Downloads/wk

0

GitHub Stars

324

Maintenance

Last Commit

3mos ago

Contributors

5

Package

Dependencies

0

License

MIT

Categories

Readme

pywasm: A WebAssembly interpreter written in pure Python.

Build Status

A WebAssembly interpreter written in pure Python.

The wasm version currently in use is: WebAssembly Core Specification, W3C Recommendation, 5 December 2019. Just like Firefox or Chrome does.

Installation

$ pip3 install pywasm

Some simple examples

  1. First we need a wasm module! Grab our ./examples/fib.wasm file and save a copy in a new directory on your local machine. Note: fib.wasm was compiled from ./examples/fib.c by WasmFiddle.

  2. Now, compile and instantiate WebAssembly modules directly from underlying sources. This is achieved using the pywasm.load method.

import pywasm
# pywasm.on_debug()

runtime = pywasm.load('./examples/fib.wasm')
r = runtime.exec('fib', [10])
print(r) # 55

A brief description for ./examples

FileDescription
./examples/add.wasmExport i32.add function
./examples/env.wasmCall python/native function in wasm
./examples/fib.wasmFibonacci, which contains loop and recursion
./examples/str.wasmExport a function which returns string
./examples/sum.wasmEqual difference series summation

Of course there are some more complicated examples!

Test

$ python3 ./test/test_spec.py

Tested in the following environments:

  • Python >= 3.6

Thanks

License

MIT

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100