Skip to main content

`wasmer` 包的 Cranelift 编译器(用于编译 WebAssembly 模块)

项目描述

瓦斯默徽标Wasmer Python,Cranelift 编译器PyPI 版本 Wasmer Python 文档 Wasmer PyPI 下载 Wasmer Slack 频道

wasmer是一个完整且成熟的 Python WebAssembly 运行时。wasmer_compiler_cranelift提供 Cranelift 编译器 wasmer,以便wasmer能够编译 WebAssembly 模块。

存在其他编译器:

  • wasmer_compiler_llvm,
  • wasmer_compiler_singlepass.

要获得更完整的视图,请参阅wasmer本身的文档。

安装

此包必须与wasmer包一起使用,因此:

$ pip install wasmer
$ pip install wasmer_compiler_cranelift

用法

任何引擎都wasmer.engine可以将 wasmer_compiler_cranelift.Compiler类作为参数:

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))

文档

浏览 https://wasmerio.github.io/wasmer-python/api/wasmer_compiler_cranelift/上的文档。

或者,运行just build compiler-cranelift后跟just doc以在 docs/api/wasmer_compiler_cranelift.html.

下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

内置发行版

wasmer_compiler_cranelift_py310-1.0.0-cp310-none-win_amd64.whl (1.4 MB 查看哈希

已上传 cp310