Skip to content

gubaojian/py-wasmi

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

py-wasmi

A WebAssembly interpreter by pure Python. WASM version: WebAssembly Core Specification W3C Working Draft, 4 September 2018

Requirements

  • 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.

Install

$ 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.

Example

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

FAQ

  • How is the py-wasm performance?

Why care about performance on Python?

License

WTFPL

About

WebAssembly Interpreter by pure Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.5%
  • WebAssembly 1.2%
  • C 0.3%