
Ask HN: Pros and cons of creating a Webassembly to Python bytecode lib? - sametmax
A lot of noise is made about webassembly these days, and I love it. Unfortunaly, I don&#x27;t think it mean we will see Python on the browser any time soon, as downloading the heavy Python runtime just for that seems overkill. Except may be if we ship microPython.<p>However, we could leverage it for a usage of Python in electron apps and in Node.js without RPC.<p>But I&#x27;m more excited about getting ride of the &quot;compiled extensions&quot; hell in Python.<p>Indeed, despite all the efforts of the community, creating the wheel standard, providing tooling, etc. installing non pure-Python libs are still a pain for new commers, albeit a lesser one. And creating wheel for a compiled extension is still much more complicated than it should be.<p>My skills in low level dev being very poor, I&#x27;m asking the crowd here:<p>- would it be possible to create a pure Python lib to translate WASM into an importable pyc file?<p>- what would be the result performance wise?<p>- would it be worth it?<p>My educated guess would be that you would loose performances, because you would have to translate low level data structures to high level ones. But still it would let the package manager do the following:<p>- try to use the compiled dist, such as a wheel. Failing that...<p>- try to compile the WASM code to a binary.  Failing that...<p>- turn the code into bytecode and  use the library, just in a slower way.<p>It would allow to write a Rust&#x2F;C Python extension garantied to be easily installable on a development machine for a beginer, but can be easily turned into something fast for production.<p>If WASM gets popular, it also means being able to use libs from Go, D, Haskell, etc in a pretty straigforward way.
======
jventura
> would it be worth it?

Nobody can tell at this point in time.. Nevertheless, regarding Python in the
browser, there's Brython [0] which works, although I don't know how's using it
in production..

[0] [https://brython.info/](https://brython.info/)

~~~
sametmax
Brython is impressive. It renders quite well a lot of Python features. Even
things like yield from, sets, generator.send(), dict.fromkeys, multiple
inheritance and 0b1100101.

But there are several problems with brython:

\- it can't render some obscure Python features. It's very hard to do a
complete Python implementation. E.g: metaclass will fail.

\- debugging is terrible.

\- 120ko gziped to pay upfront, just to write code. No virtual dom or routing.

Interesting concept none of the less. In electron it can be interesting.

------
sametmax
I'm a bit sad there is not any answer to this but I guess this is a
complicated topic.

Maybe I should bring that to the Python-idea mailing list instead.

