5 ms·
> py2wasm converts your Python programs to WebAssembly, running them at 3x faster speeds This is clearly written in the article, but I hope that the impatient
by wdroz 2y ago
> py2wasm converts your Python programs to WebAssembly, running them at 3x faster speeds
This is clearly written in the article, but I hope that the impatient readers will understand that this is 3 times faster than the CPython wasm, not the native CPython.
- IshKebab 2y agoYeah more honest would have been "2x slower"!
- williamstein 2y agoEven more honest would be “on one particular microbenchmark that everybody optimizes for”. That said, this seems like a really cool project that could have some real value! It still fully depends on having the full CPython runtime environment, but that means it could work correctly with most existing code and libraries (including numpy and script).
- wasiwin 2y agoFrom what I could tell, Nuitka dynamically loads extension modules so this wouldn't work with Webassembly modules which are statically linked. If I could be enhanced to automatically build wheels of packages like numpy and statically link them, then that could bring extensions to Wasm and be very cool. IIRC, Google does this with their Python apps so the concept does exist but don't think I've seen any OSS tooling trying that.
- 5- 2y agoeven more specifically, 3 times faster than wasmer's build of cpython (whatever that is), running on their runtime. i'd be curious to see this benchmark extended, as in my own experience toying with python-like interpreters, you get ~2x slowdown (like their end result) from just compiling to wasm/wasi with clang and running in any 'fast' runtime (e.g. node or wasmtime).
- deleted 2y ago[deleted]
- syrusakbary 2y agoHey, I'd love to reproduce the ~2x slowdown you commented from running the workload in Native CPython compared to Wasm CPython (in any runtime, browser or outside). Any tip would be helpful so we can debug it. If your claims are accurate, we can easily get py2wasm even running faster than native CPython! Note: we benchmarked in a M3 Max laptop, so maybe there's some difference there?
- deleted 2y ago[deleted]
- kelp 2y agoHere is a trivial example, also on a M3 Max: cat hello.py print("Hello, Wasm!") time python3 ./hello.py Hello, Wasm! ________________________________________________________ Executed in 26.86 millis fish external usr time 16.37 millis 0.13 millis 16.24 millis sys time 7.25 millis 1.14 millis 6.11 millis time wasmer hello.wasm Hello, Wasm! ________________________________________________________ Executed in 84.77 millis fish external usr time 50.26 millis 0.14 millis 50.12 millis sys time 28.97 millis 1.21 millis 27.76 millis time wasmtime hello.wasm Hello, Wasm! ________________________________________________________ Executed in 141.72 millis fish external usr time 120.86 millis 0.13 millis 120.72 millis sys time 16.65 millis 1.20 millis 15.45 millis
- 5- 2y agonote that i'm not claiming 2x slowdown for cpython. but here's one test i've run just now: using your test file, i've run this one-liner on my x86_64 linux laptop in https://pyodide.org/en/stable/console.html https://pyodide.org/en/stable/console.html in chromium (v8) and natively (pyodide's urllib doesn't handle https for some reason): import requests;exec(requests.get('https://gist.githubusercontent.com/syrusakbary/b318c97aaa8de6e8040fdd5d3995cb7c/raw/1c6cc96cf98bd7bd41c81ba9d10dc4d19b1c3e53/pystone.py').text) native: ~470k pyodide: ~200k i.e. ~2.4x slowdown