Skip to main content

python bindings for the binaryen webassembly library

Project description

saythanks Latest Version

Python interface to the Binaryen library

This module provides a Python interface to the binaryen webassembly library.

That library has to be installed separately, make sure it is available on your system as a shared library. You may need to add something to your link library search path to let python pick it up.

Requires Python 3.6 or newer. Also works on pypy3 (because it uses cffi).

Software license: MIT


Running the following code:

import binaryen

module = binaryen.ModuleCreate()
params = binaryen.TypeCreate([binaryen.TypeInt32(), binaryen.TypeInt32()], 2)
results = binaryen.TypeInt32()
x = binaryen.LocalGet(module, 0, binaryen.TypeInt32())
y = binaryen.LocalGet(module, 1, binaryen.TypeInt32())
add = binaryen.Binary(module, binaryen.AddInt32(), x, y)
adder = binaryen.AddFunction(module, b"adder", params, results, binaryen.ffi.NULL, 0, add)

results in the following Webasm Text output:

 (type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
 (func $adder (; 0 ;) (param $0 i32) (param $1 i32) (result i32)
   (local.get $0)
   (local.get $1)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pybinaryen, version 1.7
Filename, size File type Python version Upload date Hashes
Filename, size pybinaryen-1.7.tar.gz (14.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page