Giter Club home page Giter Club logo

pywasm's Introduction

pywasm: A WebAssembly interpreter written in pure Python.

Build Status

A WebAssembly interpreter written in pure Python. JIT used.

The wasm version currently in use is: WebAssembly Core Specification W3C Working Draft, 4 September 2018. Just like Firefox or Chrome does.

Installation

$ pip3 install pywasm

Some simple examples

  1. First we need a wasm module! Grab our ./examples/fib.wasm file and save a copy in a new directory on your local machine. Note: fib.wasm was compiled from ./examples/fib.c by WasmFiddle.

  2. Now, compile and instantiate WebAssembly modules directly from underlying sources. This is achieved using the pywasm.load method.

import pywasm
# pywasm.on_debug()

vm = pywasm.load('./examples/fib.wasm')
r = vm.exec('fib', [10])
print(r) # 55

A brief description for ./examples

File Description
./examples/add.wasm Export i32.add function
./examples/env.wasm Call python/native function in wasm
./examples/fib.wasm Fibonacci, which contains loop and recursion
./examples/str.wasm Export a function which returns string
./examples/sum.wasm Equal difference series summation

Test

python ./tests/test_spec.py

Tested in the following environments:

  • Python 3.7.3
  • Python 3.6.5

Thanks

License

WTFPL

pywasm's People

Contributors

mohanson avatar spencerpark avatar thijstriemstra avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.