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 Recommendation, 5 December 2019. 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()
runtime = pywasm.load('./examples/fib.wasm')
r = runtime.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
$ python3 ./test/test_spec.py
Tested in the following environments:
- Python >= 3.6
Thanks
License
Metadata
Release files for pywasm 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pywasm-1.0.1.tar.gz | 28.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pywasm-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 56.4 kB
Release files / pywasm-1.0.1.tar.gz
| Download URL | pywasm-1.0.1.tar.gz |
|---|---|
| Size | 28.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a94cbcafe88a4416343323eec2c4e1b6e1732b94431dd7a2a631957727c986f3
|
|
BLAKE2b-256 checksum How to use checksums |
e320712ed04eac39e16b07a543d1d07ed8be54f8f3dd30cd1905cdcde331250d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / pywasm-1.0.1-py3-none-any.whl
| Download URL | pywasm-1.0.1-py3-none-any.whl |
|---|---|
| Size | 28.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7efd2e805bbf13773d43b8e9f85fa493b03d0413a36c8e3ba2d621317f99e7b2
|
|
BLAKE2b-256 checksum How to use checksums |
230ac6cdb30c8ab16f19a489c38abcef81b15e89c4f8172b4e93b0d7a414b557
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for pywasm 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.