WebAssembly Interpreter by pure Python
Project description
pywasm: A WebAssembly interpreter written in pure Python.
A WebAssembly interpreter written in pure Python.
The wasm version currently in use is: WebAssembly Core Specification W3C Working Draft, 4 September 2018. Just like Firefox or Chrome does.
Installation
$ pip3 install pywasm
Some simple examples
-
First we need a wasm module! Grab our
./examples/fib.wasmfile and save a copy in a new directory on your local machine. Note:fib.wasmwas compiled from./examples/fib.cby WasmFiddle. -
Now, compile and instantiate WebAssembly modules directly from underlying sources. This is achieved using the
pywasm.loadmethod.
import pywasm
# pywasm.on_debug()
vm = pywasm.load('./examples/fib.wasm')
r = vm.exec('fib', [10])
print(r) # 55
A brief description for ./examples
| File | Description |
|---|---|
| ./examples/add.wasm | Export i32.add function |
| ./examples/env.wasm | Call python/native function in wasm |
| ./examples/fib.wasm | Fibonacci, which contains loop and recursion |
| ./examples/str.wasm | Export a function which returns string |
| ./examples/sum.wasm | Equal difference series summation |
Of course there are some more complicated examples!
- Zstandard decompression algorithm: https://github.com/dholth/zstdpy
- Run AssemblyScript on pywasm: https://github.com/mohanson/pywasm_assemblyscript
Test
$ python ./test/test_spec.py
Tested in the following environments:
- Python >= 3.6
Thanks
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pywasm-0.4.8.tar.gz.
File metadata
- Download URL: pywasm-0.4.8.tar.gz
- Upload date:
- Size: 23.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47c5321d77c60b3de74c5137c122fb9bf0f050efe8f8bc3d00d8c9b42dcf6880
|
|
| MD5 |
f11370ca2dae9e57335e7b3cd0d246e0
|
|
| BLAKE2b-256 |
e6e19291ba9533f94f1ea9b19eb519ad7a125db2d556350c6ee68d72e533e28f
|
File details
Details for the file pywasm-0.4.8-py3-none-any.whl.
File metadata
- Download URL: pywasm-0.4.8-py3-none-any.whl
- Upload date:
- Size: 23.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66a0099dac0606b32d9482314af9d45704522c8d68444265ac4e088effd4a535
|
|
| MD5 |
8ddb04533306d4fda1aa97b642142c7a
|
|
| BLAKE2b-256 |
72d97beb72ad2ffd591ca96978e80027708c50647ebf28aa35f2f5836e725418
|