Interactions between WebAssembly and Python
Project description
WasmPy
Interacting with WebAssembly code from python.
Wasmpy is a fairly lightweight layer that sits between Python and the WebAssembly code. When attempting to import a WebAssembly file, the file is read and it is converted into native machine code for native speeds.
This project is intended to be used in conjunction with wasmpy-build, although it does support regular WebAssembly files too.
Installing
Install the latest version:
$ python -m pip install wasmpy
Or build and install from source:
$ git clone https://github.com/olivi-r/wasmpy.git
$ cd wasmpy
$ python setup.py install
Usage
WasmPy defines import hooks to make the loading of WebAssembly binary files much easier! Just import the WasmPy
library then you are good to go!
Example:
If you have the following project setup:
|- my_wasm_file.wasm
|- main.py
Then in main.py
the following code will load the WebAssembly file:
import wasmpy
import my_wasm_file
The hook also allows importing the files from submodules, eg:
|- main.py
|- my_module
| |- my_wasm_file.wasm
Then
import wasmpy
from my_module import my_wasm_file
Functions can be called with the call function from the imported module:
import wasmpy
import wasm_math
wasm_math.call("add")(...)
This is due to WebAssembly supporting exported names that may not be valid Python names, such as add two numbers
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 Distributions
Hashes for wasmpy-0.1.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 897cd0e1f61e9502c9cb04ff9c2b85ae5da9b6b113358514728f646d471f5547 |
|
MD5 | 41ef01742be86bd3b9b7e145a1742617 |
|
BLAKE2b-256 | 360ad0577cb211f69fbefaf2f8db5d4ecc63b563355aa01597d590709f76bc54 |
Hashes for wasmpy-0.1.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b071abbaed4ac1573c9c2b5f5cc6edfcfdab9daa0be6338eead5d68f3b0e313 |
|
MD5 | 3e291dd7feaf245f89f027f14e7731b6 |
|
BLAKE2b-256 | dc3bde52e7d22659fda489779e48e593699e68b7459f0884e3d3a02d3c40a48c |
Hashes for wasmpy-0.1.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02bd75b4de508d91f4440adc736fd444ccff27b707e481d0a656f61547d6abcf |
|
MD5 | 9e9188874501ec2df43b438e62382f7c |
|
BLAKE2b-256 | 732573ff77871a0a80bb94d410ea53cd9c6a9a7e1ac29f030bc8f4e79f1077c4 |
Hashes for wasmpy-0.1.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6ba01da7fcd6dcad0d1f9c38e38d5572621ad53bf1540bd463e586627a52ef6 |
|
MD5 | d646a4000c6a32e8eafa920b254b7c10 |
|
BLAKE2b-256 | f48f2799342f36bf4e8fcf80143d06a84853c036a9eb5cd46f8d4280fecbe49d |
Hashes for wasmpy-0.1.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63ca09648d13d963469245d4d9fa6d15bfa9d758349ddb01e8e24a8ae857c7cb |
|
MD5 | a246d6ff3ffb753a30cd562b9287e4df |
|
BLAKE2b-256 | 1b1137ed4620adecd19a5b3a88febb02c81aece2d02e00cc8aff53a70392fe6f |
Hashes for wasmpy-0.1.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a29265fee12dbc5ce18486c0e174b7ffed4584970f95ea1c37813c13c2a5db32 |
|
MD5 | 7ecab00815a9563248bc5661f0485bfa |
|
BLAKE2b-256 | 2a26094cb39d53417792d2f6eb6ecaf2332141082ea564409a266307711ffa25 |