1

Wasmer unveils Python to Wasm compiler

 1 week ago
source link: https://www.infoworld.com/article/3715388/wasmer-unveils-python-to-wasm-compiler.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Wasmer unveils Python to Wasm compiler

py2wasm draws on Nuitka to convert Python programs to WebAssembly and run them at 3x faster speeds, Wasmer says.

By Paul Krill

Editor at Large,

InfoWorld | Apr 24, 2024 2:00 am PDT

Speed, fast, performance

Ollyy/Shutterstock

WebAssembly runtime maker Wasmer has unveiled py2wasm, a Python-to-WebAssembly compiler that transforms Python programs to the WebAssembly (aka Wasm) binary instruction format.

Using a fork of the Nuitka Python compiler, py2wasm converts Python programs to Wasm, allowing them to run without interpreter overhead. Introduced April 18, py2wasm addresses a situation in which the performance of Python programs in WebAssembly has been less than ideal, Wasmer founder and CEO Syrus Akbary wrote in a blog post. Akbary said that py2wasm gets about 70% of native Python speed, and is about 2.5x to 3x faster than the Python interpreter.

Wasmer used Nuitka to speed up Python in WebAssembly because most of the hard work was already done to transpile Python code into underlying CPython interpreter calls. Nuitka works by transpiling a program’s Python calls into C, using inner CPython API calls, Akbary said. Nuitka supports most Python programs, and also can work as a code obfuscator, preventing anyone from decompiling a program.

Because Nuitka does not yet work with Python 3.12, Wasmer had to recompile Python to Python 3.11 to WASI (WebAssembly Systems Interface) and use the generated libpython.a archive. Nuitka then could use this library when targeting WASI and WebAssembly to build the executable. Because the Nuitka transpiler executed in a 64-bit architecture but generated code was running in a 32-bit architecture, work had to be done to fix the prototype, Akbary said.

0 seconds of 26 secondsVolume 0%
This ad will end in 26

InfoWorld Senior Writer Serdar Yegulalp contributed to this report.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK