13 ms·
Py2wasm – A Python to WASM Compiler
- 2genders46966 2y ago[dead]
- 2genders13908 2y ago[dead]
- 2genders35549 2y ago[flagged]
- 2genders29067 2y ago[flagged]
- SEXMCNIGGA6180 2y ago[flagged]
- SEXMCNIGGA40191 2y ago[dead]
- SEXMCNIGGA30273 2y ago[dead]
- 2genders47876 2y ago[dead]
- sexmc28768 2y ago[flagged]
- sexmc20177 2y ago[flagged]
- grondilu 2y agoNice. Maybe a pie in the sky but considering how prevalent python is in machine learning, how likely is it that at some point most ML frameworks written in python become executable on a web browser through WASM?
- ilyaraz90 2y agoYou can already run inference of many modern ML models in-browser via, e.g., https://huggingface.co/docs/transformers.js/en/index https://huggingface.co/docs/transformers.js/en/index .
- miohtama 2y agoDepending on the underling machine learning activity (GPU/no-GPU) it should be already possible today. Any low level machine learning loops are raw native code or GPU already and Python’s execution speed is irrelevant here. The question is do the web browsers and WebAssembly have enough RAM to do any meaningful machine learning work.
- westurner 2y agoWebGL, WebGPU, WebNN Which have better process isolation; containers or Chrome's app sandbox at pwn2own how do I know what is running in a WASM browser tab? JupyterLite, datasette-lite, and the Pyodide plugin for vscode.dev ship with Pyodide's WASM compilation of CPython and SciPy Stack / PyData tools. `%pip install -q mendeley` in a notebook opened with the Pyodide Jupyter kernel works by calling `await micropip.install(["mendeley"])` IIRC. picomamba installs conda packages from emscripten-forge, which is like conda-forge: https://news.ycombinator.com/item?id=33892076#33916270 https://news.ycombinator.com/item?id=33892076#33916270 : > FWIU Service Workers and Task Workers and Web Locks are the browser APIs available for concurrency in browsers sqlite-wasm, sqlite-wasm-http, duckdb-wasm, (edit) postgresql WASM / pglite ; WhatTheDuck, pretzelai ; lancedb/lance is faster than pandas with dtype_backend="arrow" and has a vector index "SQLite Wasm in the browser backed by the Origin Private File System" (2023) https://news.ycombinator.com/item?id=34352935#34366429 https://news.ycombinator.com/item?id=34352935#34366429 "WebGPU is now available on Android" (2024) https://news.ycombinator.com/item?id=39046787 https://news.ycombinator.com/item?id=39046787 "WebNN: Web Neural Network API" https://www.w3.org/TR/webnn/ https://www.w3.org/TR/webnn/ : https://news.ycombinator.com/item?id=36159049 https://news.ycombinator.com/item?id=36159049 "The best WebAssembly runtime may be no runtime" (2024) https://news.ycombinator.com/item?id=38609105 https://news.ycombinator.com/item?id=38609105 (Edit) emscripten-forge packages are built for the wasm32-unknown-emscripten build target, but wasm32-wasi is what is now supported by cpython (and pypi?) https://www.google.com/search?q=wasm32-wasi+conda-forge https://www.google.com/search?q=wasm32-wasi+conda-forge
- ubj 2y agoNice--it's great to see more options for interoperability between Python and WASM. I was aware of Pyodide [1], but Py2wasm seems to be a tool for compiling specific scripts into WASM rather than having an entire Python distribution in the browser. Please correct me if I'm misunderstanding the difference between the two however. [1]: https://pyodide.org/en/stable/ https://pyodide.org/en/stable/
- theanonymousone 2y agoThat's my understanding as well. And Pyodide being a great piece of engineering, is still lagging behind compiled Wasm languages in terms of footprint at least and performance sometimes, unfortunately.
- 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
- barfard 2y ago[dead]
- SEXMCNIGGA22197 2y ago[flagged]
- boomskats 2y agoSo I had a look at the repo/branches at https://github.com/wasmerio/py2wasm https://github.com/wasmerio/py2wasm. This might be a nit, but in the spirit of OSS: if I'd done this work, I'd have contributed it to upstream Nuitka. I definitely would not have forked a whole new GitHub repo and given it a completely different name. What's the rationale for creating a new project and calling it py2wasm? Am I missing something?
- Ennea 2y agoMy first thought upon reading Nuitka's name in the article was along the lines of "I hope they've contributed some of this to Nuitka". Not a very nice trend.
- __s 2y agoWhat trend? Forking happens all the time. It's one of the benefits of open source. I've often made PRs on github to projects while shifting projects I work on to my fork since upstreaming can take months or often never happen Granted, Nuitka is an active project, but wasmer.io is going to have a much more focused desire with their changes that they can deploy, meanwhile getting it upstream will have to go through rounds of review & adjustments https://github.com/rustwasm/wasm-pack/pull/937 https://github.com/rustwasm/wasm-pack/pull/937 this small change took over 2 years to merge. Open source takes time
- spencerflem 2y agoReading the blog post- they are contributing it upstream
- boomskats 2y agoWell, reading the blog post, they're announcing a whole new compiler. I'd encourage you to have a look at the PR their post links to.
- syrusakbary 2y agoThanks for the feedback! I'm Syrus, main author of the work on py2wasm. We already opened a PR into Nuitka to bring the relevant changes upstream: https://github.com/Nuitka/Nuitka/pull/2814 https://github.com/Nuitka/Nuitka/pull/2814 We envision py2wasm being a thin layer on top of Nuitka, as also commented in the article (not a fork as it is right now, although forking got us into the proof of concept a bit faster!). From what we gathered, we believe that there's usefulness on having py2wasm as a separate package, as py2wasm would also need to ship the precompiled Python distribution (3.11) for WASI (which will not be needed for the other Nuitka use cases), apart of also shipping other tools that are not directly relevant for Nuitka
- theanonymousone 2y agoIt may be a stupid question, but is there already some DOM access or a dedicated package that allows writing web applications in this compiled python?
- miohtama 2y agoYes. Here is an example how to integrate Python to React front end https://blog.pyodide.org/posts/react-in-python-with-pyodide/ https://blog.pyodide.org/posts/react-in-python-with-pyodide/ Similar examples for raw DOM manipulation should be available for Pyodide as well. It has bindings to all JS code, so it can do everything that JS can do.
- theanonymousone 2y agoThanks. I know about the one for Pyodide. Is it confirmed that it works for this new py2wasm compiler?
- spankalee 2y agoWith WasmGC finalized, I hope we see more compilers that target it instead of including their own GC. It's could be a new interpreter, or maybe a version of CPython that uses WasmGC structs for all Python objects, or a compiler similar to this but that targets WasmGC directly.
- Jasper_ 2y agoWasmGC is not really what you think it is. Think of it as a full-on replacement for the linear memory model, not as a way to add GC to it. It's exceptionally difficult to port a language runtime over to WasmGC -- it doesn't even offer finalizers, so __del__ can't implemented correctly (even ignoring the issues with existing __del__ semantics in Python leading to compatibility issues). It doesn't support interior pointers, so you can't have a pointer into the middle of an array. There's no easy way to port Python to WasmGC.
- kevingadd 2y agoCurrent WasmGC is missing a lot of critical features for production grade GC, like finalization and interior pointers. It's really promising though, so I think once the gaps get filled in you'll see a bunch of runtimes start moving over - maybe .NET, etc.
- weinzierl 2y agoI want the opposite. The Python VM is everywhere. Can't I just run my WASM on Python? (The WASM runtime must be pure Python, installing C/C++ extensions is against the spirit of this.)
- SEXMCNIGGA27725 2y ago[flagged]
- ptx 2y agoHow come the CPython interpreter is so slow when compiled to WebAssembly? According to the figures in the article, it runs at 23% the speed of the native version. Wasmer, which they're using in the benchmarks, should run code "at near-native speeds" according to the docs[0]. Apparently it has multiple compiler backends, so maybe the choice of backend affects the result? [0] https://docs.wasmer.io/runtime https://docs.wasmer.io/runtime
- lenerdenator 2y agoWould it be too late to call it PyToWasm? I know Python 2 has been EOL for over four years now but you still see it (much to the chagrin of decent engineers everywhere) in the wild; could generate confusion.
- SEXMCNIGGA22793 2y ago[flagged]
- SEXMCNIGGA15705 2y ago[flagged]
- SEXMCNIGGA38268 2y ago[flagged]
- SEXMCNIGGA34706 2y ago[dead]
- spxneo 2y agoso does this mean we can run FastAPI inside a browser?
- SEXMCNIGGA26553 2y ago[flagged]
- SEXMCNIGGA9292 2y ago[flagged]
- lagt_t 2y agoWhat's the hello world wasm file size?
- kelp 2y agols -lh hello.wasm -rw-r--r--@ 1 tcole staff 24M Apr 22 14:18 hello.wasm This is on macOS. That is hello.py compiled to wasm with Py2wasm.
- theanonymousone 2y agoYou got it to work? For me it complains about some header files missing and breaks the nuitka installed on the system.
- somesun 2y agoI wonder what's the meaning of doing this , if hello world program need 20M to download before run ?
- theanonymousone 2y agoWow! 24M makes it even less practical than interpreted pyodide.
- syrusakbary 2y agoIndeed, this can be way further optimized. For example, you can probably do a wasm-strip and wasm-opt passes that would leave the wasm file being ~5-10Mb. Still very big, but a bit more reasonable. The good thing is that thanks to Nuitka you could actually do some tree shaking and only include the imported files and not everything in between (although this might break other behavior such as eval and so).
- SEXMCNIGGA26559 2y ago[dead]
- SEXMCNIGGA26313 2y ago[flagged]
- SEXMCNIGGA5794 2y ago[flagged]
- SEXMCNIGGA32276 2y ago[flagged]
- SEXMCNIGGA43288 2y ago[flagged]
- SEXMCNIGGA25974 2y ago[dead]
- SEXMCNIGGA26666 2y ago[flagged]
- SEXMCNIGGA20545 2y ago[flagged]
- SEXMCNIGGA40029 2y ago[flagged]
- SEXMCNIGGA31119 2y ago[flagged]
- SEXMCNIGGA30292 2y ago[flagged]
- SEXMCNIGGA41234 2y ago[flagged]
- SEXMCNIGGA2036 2y ago[flagged]
- SEXMCNIGGA45669 2y ago[flagged]
- SEXMCNIGGA19401 2y ago[flagged]
- SEXMCNIGGA237 2y ago[flagged]
- SEXMCNIGGA8979 2y ago[dead]
- SEXMCNIGGA43492 2y ago[dead]
- SEXMCNIGGA44908 2y ago[dead]
- SEXMCNIGGA45429 2y ago[dead]
- SEXMCNIGGA20011 2y ago[dead]
- SEXMCNIGGA873 2y ago[dead]
- SEXMCNIGGA7245 2y ago[dead]
- umvi 2y agoWhat's up with the botspam in this thread? Looks like hundreds of sex bot accounts are being created. Pages seem really slow to load currently... someone should notify dang.
- SEXMCNIGGA18460 2y ago[dead]
- SEXMCNIGGA44847 2y ago[dead]
- SEXMCNIGGA22606 2y ago[dead]
- SEXMCNIGGA38282 2y ago[dead]
- SEXMCNIGGA33367 2y ago[dead]
- SEXMCNIGGA2949 2y ago[dead]
- SEXMCNIGGA18150 2y ago[dead]
- SEXMCNIGGA28008 2y ago[dead]
- SEXMCNIGGA14809 2y ago[dead]
- SEXMCNIGGA7379 2y ago[dead]
- SEXMCNIGGA29758 2y ago[dead]
- SEXMCNIGGA27931 2y ago[dead]
- SEXMCNIGGA19328 2y ago[dead]
- 2genders25554 2y ago[dead]
- 2genders22750 2y ago[dead]
- 2genders12752 2y ago[dead]
- 2genders37544 2y ago[dead]
- 2genders20124 2y ago[dead]
- 2genders6254 2y ago[dead]
- 2genders15635 2y ago[flagged]
- 2genders19703 2y ago[flagged]
- 2genders37480 2y ago[flagged]
- 2genders5140 2y ago[flagged]
- 2genders46577 2y ago[flagged]
- vimota 2y ago> We worked on py2wasm to fulfill our own needs first, as we want to accelerate Python execution to the maximum, so we can move our Python Django backend from Google Cloud into Wasmer Edge. I was under the impression that Django was stateful and not meant to be run in a serverless/edge cloud. Is that not the case or are you planning to do a special setup to support that?
- 2genders716 2y ago[dead]
- 2genders13469 2y ago[dead]
- 2genders28600 2y ago[dead]
- 2genders20299 2y ago[flagged]
- SEXMCNIGGA504 2y ago[dead]
- SEXMCNIGGA47748 2y ago[flagged]
- 2genders25672 2y ago[flagged]
- SEXMCNIGGA19236 2y ago[flagged]
- 2genders7267 2y ago[flagged]
- 2genders20975 2y ago[flagged]
- 2genders34842 2y ago[flagged]
- 2genders10037 2y ago[flagged]
- 2genders12521 2y ago[flagged]
- 2genders48337 2y ago[flagged]
- 2genders31778 2y ago[flagged]
- 2genders39997 2y ago[flagged]
- 2genders24085 2y ago[flagged]
- 2genders20059 2y ago[flagged]
- 2genders46677 2y ago[flagged]
- 2genders45784 2y ago[flagged]
- 2genders37005 2y ago[flagged]
- 2genders10659 2y ago[flagged]
- 2genders3617 2y ago[flagged]
- 2genders17397 2y ago[flagged]
- SEXMCNIGGA14282 2y ago[flagged]
- SEXMCNIGGA15477 2y ago[flagged]
- SEXMCNIGGA20534 2y ago[dead]
- SEXMCNIGGA30430 2y ago[flagged]
- SEXMCNIGGA7771 2y ago[flagged]
- SEXMCNIGGA12823 2y ago[flagged]
- SEXMCNIGGA43331 2y ago[dead]
- SEXMCNIGGA34137 2y ago[dead]
- SEXMCNIGGA10750 2y ago[dead]
- SEXMCNIGGA15779 2y ago[dead]
- SEXMCNIGGA23941 2y ago[dead]
- SEXMCNIGGA32196 2y ago[dead]
- SEXMCNIGGA37114 2y ago[dead]
- SEXMCNIGGA44676 2y ago[dead]
- indianmilf36765 2y ago[dead]
- indianmilf7653 2y ago[dead]
- indianmilf44940 2y ago[dead]
- indianmilf28572 2y ago[dead]
- indianmilf32545 2y ago[dead]
- indianmilf41566 2y ago[flagged]
- indianmilf34967 2y ago[flagged]
- indianmilf7542 2y ago[flagged]
- sexmc21609 2y ago[flagged]
- sexmc32904 2y ago[flagged]
- sexmc19673 2y ago[flagged]
- sexmc41709 2y ago[flagged]
- sexmc21258 2y ago[flagged]
- sexmc10662 2y ago[flagged]
- sexmc22673 2y ago[flagged]
- sexmc39654 2y ago[flagged]
- sexmc6561 2y ago[flagged]
- sexmc26257 2y ago[flagged]