Universal WASM loader for Python
Project description
universalWasmLoader-py
Universal WASM loader for Python — the Python port of
universalWasmLoader-js. Loads and
instantiates WebAssembly modules and, when a companion .wit file is present, applies the
Canonical ABI so you call WIT exports with idiomatic Python values (int/float, bool,
str) instead of raw i32/pointer pairs.
- PyPI package:
universal-wasm-loader - WASM runtime:
wasmtime≥ 26.0.0 - License: MIT
Install
pip install universal-wasm-loader
Usage
wasm_import() loads a .wasm module and hands you its exports as a dict of
ready-to-call Python functions — pull one out, bind it to a name, and call it
like any other function:
import asyncio
from universal_wasm_loader import wasm_import
async def main():
# Load the module. Exports come back as a dict of callables.
exports = await wasm_import("./math.wasm")
# Turn a WASM export into a Python function and call it.
# (companion math.wit -> `calculate: func(a: s32, b: s32) -> s32`)
calculate = exports["calculate"]
print(calculate(1, 2)) # 3
asyncio.run(main())
When a companion <name>.wit sits next to the .wasm, the Canonical ABI is
applied automatically: kebab-case WIT names become camelCase keys, and arguments
and results are idiomatic Python values (bool, str) — no manual i32/pointer
handling:
# strings_50.wasm + strings_50.wit -> greet, shout, str-len
exports = await wasm_import("./strings_50.wasm")
greet = exports["greet"]
print(greet("World")) # "Hello, World!" (str in, str out)
print(exports["strLen"]("hello")) # 5 (WIT export `str-len`)
create_singleton() (one shared instance) and InstancePool() (N instances for
concurrent workloads) are also exported. See the
project on GitHub for the
full API, examples, and source.
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 universal_wasm_loader-1.0.1.tar.gz.
File metadata
- Download URL: universal_wasm_loader-1.0.1.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
254f946fbff78341588b83d525cfe6659050ee415382e89d23ae95e762fc6f6d
|
|
| MD5 |
af8c19d525b6b971594596c4d76a1093
|
|
| BLAKE2b-256 |
07f4ebff9bb40afb2d1d96a5e065bcc8ba0d66e3fb5619368b00b1ac73cdf80f
|
File details
Details for the file universal_wasm_loader-1.0.1-py3-none-any.whl.
File metadata
- Download URL: universal_wasm_loader-1.0.1-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74105c2990dd1d53d0920c1657e1df534c765b0ba350f55ed731e624e1446337
|
|
| MD5 |
8f15e446b4dcc9a0b4b4728a0c4c18de
|
|
| BLAKE2b-256 |
9f56206676c3d01b8a38d7aa8894c6666ba01ada0451d9b905799d1b2acc07c9
|