Skip to content

pywasm 1.0.0 release

Mohanson edited this page May 8, 2020 · 3 revisions

In the past period of time, pywasm has increased its horsepower and upgraded its version number from 0.4.6 version to 1.0.0 , which means that it is ready for product!

So, what is pywasm? In short, pywasm is a WebAssembly interpreter written in pure Python. Homepage: https://github.com/mohanson/pywasm

What did pywasm do during this time

Rewrite the LEB128 variable-length integer encoding algorithm. It is the first wheel on the LEB128 algorithm in the Python environment. You can directly download and use it by pip install leb128. Compared to version 0.4.6, it Brought about 120% performance improvement.

Rewrite WebAssembly Parser. To run a piece of code, you must first parse it, isn't it? Faster, clearer code!

Rewrite floating-point instruction. At 0.4.6, floating-point numbers are done using Python's built-in float, but this is problematic, because Python's float is almost completely incompatible with the IEEE 754 standard. Now, numpy has undertaken this part. Python, why are you reluctant to design the two basic types of integers and floating-point numbers? Infinite-length integers and floating-point numbers look attractive, but for the system-development is really a disaster.

Rewrite the Runtime. The current code structure is more in line with the virtual machine structure described by the WebAssembly core specification. This is optimized for ease of reading.

Replace the single stack structure with a multi-stack structure. Each function call has a brand new stack, although it is different from the specification, but it is really awesome! In addition, the advantage of multiple stacks is the rapid destruction of the call stack: when When exiting a function, just discard the function's stack without too much interaction with the parent function.

Full compatibility. In order not to disrupt the experience of early users, the upgrade remains upwardly compatible.

Full testing. The pywasm project was started 3 years ago, that time WebAssembly was still in the early stages, and the official did not release well-organized test cases. pywasm upgraded the testsuits now, for the wasm module that was parsed and verified without errors, pywasm has achieved 100% test pass.

Interesting applications of pywasm

The future

  • Thinking about the JIT or AOT plan. Although there are preliminary attempts, it needs foreign aid!
  • WASI (WebAssembly System Interface), but wait until the specification is stable.
  • Multi-threading and multi-return value support, also wait for the specification to be merged into the wasm core spec.
Clone this wiki locally