The Cranelift compiler for the `wasmer` package (to compile WebAssembly module)
Project description
Wasmer Python, the Cranelift compiler
wasmer
is a complete and mature WebAssembly runtime for
Python. wasmer_compiler_cranelift
provides the Cranelift compiler to
wasmer
, so that wasmer
is able to compile WebAssembly module.
Other compilers exist:
wasmer_compiler_llvm
,wasmer_compiler_singlepass
.
To get a more complete view, please see the documentation of the
wasmer
package itself.
Install
This package must be used with the wasmer
package, thus:
$ pip install wasmer
$ pip install wasmer_compiler_cranelift
Usage
Any engines in wasmer.engine
can take the
wasmer_compiler_cranelift.Compiler
class as argument:
from wasmer import engine, Store, Module, Instance
from wasmer_compiler_cranelift import Compiler
# Let's use the Cranelift compiler with the JIT engine…
store = Store(engine.JIT(Compiler))
# … or with the native engine!
store = Store(engine.Native(Compiler))
# And now, compile the module.
module = Module(store, open('my_program.wasm', 'rb').read())
# Now it's compiled, let's instantiate it.
instance = Instance(module)
# And get fun, for example by calling the `sum` exported function!
print(instance.exports.sum(1, 2))
Documentation
Browse the documentation at https://wasmerio.github.io/wasmer-python/api/wasmer_compiler_cranelift/.
Alternatively, run just build compiler-cranelift
followed by just doc
to generate the documentation inside
docs/api/wasmer_compiler_cranelift.html
.
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 Distributions
Built Distributions
Hashes for wasmer_compiler_cranelift_py310-1.0.0-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87993e4b43ef7ca69c7fc15ed4195e7561a77883db79907c51046056f0b80604 |
|
MD5 | 362250caeec090d36df7c062b7efe7ea |
|
BLAKE2b-256 | 325c66a31ec4744a89ffcd1e37c3f5650daa39b5be11448d064bc7104eae5090 |
Hashes for wasmer_compiler_cranelift_py310-1.0.0-cp310-cp310-manylinux_2_27_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8dc55d6f6b8debf042d97502652e5048591311813f2db0e50d3b6ba47a21813a |
|
MD5 | 8be641044d496168a002f236f58625c2 |
|
BLAKE2b-256 | 01386ac2e38f36868c31a417ff5d02ca6dc5606774c110a99aa055859229e5f6 |
Hashes for wasmer_compiler_cranelift_py310-1.0.0-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db21a81e768f3159168f7fcaf466efb09b1748d8cc821cd1062a778e11d5f5bd |
|
MD5 | 3b69c10f62c93d80c7f70c938db5a7ef |
|
BLAKE2b-256 | 69498ca8373aa307e21861c4b9871a688a4232d3f8a57e818f1cc8761d529a37 |