Hacker News new | ask | show | jobs
by eatonphil 1513 days ago
This uses Pyodide [0] under the hood [1], which is CPython compiled to WebAssembly. In all my tests of it, loading takes a long time ~5 seconds. Coldbrew [2], another distribution of CPython on Wasm, is another option with similar load times.

And Brython [3] is a completely different option without long load time: a Python interpreter implemented in JavaScript.

If load time is important, Brython is pretty nice. If feature completeness is important, Pyodide and Coldbrew are probably best.

[0] https://github.com/pyscript/pyscript/blob/main/pyscriptjs/sr...

[1] https://github.com/pyodide/pyodide

[2] https://github.com/plasticityai/coldbrew

[3] https://github.com/brython-dev/brython

5 comments

There are actually quite a few Python-in-the-browser implementations, not just those two! A couple of years ago a colleague of mine wrote up a comparison, including Brython and Pyodide:

https://anvil.works/blog/python-in-the-browser-talk

(We chose one of the Python-to-JS compilers, https://skulpt.org, for the Anvil web-app platform, because it's much lighter weight than this. It's a couple of hundred kb on the wire, and you can call to the server for any heavy lifting.)

And before all of those, 20 years ago, ActiveState had a Python ActiveX extension (in addition to Perl and TCL).
Just the word "ActiveX" brings about nightmares.
One downside with python-to-js compilers is losing easiness and speed to debug issues, which is one of the strongest points for using Python.
It also requires a server somewhere for dynamic input (i.e. Browser based notebooks).
Just 5 seconds? Sign me up. Corporate web sites take 30+ to load already.. /s
PyScript intent for using pyodide was usability with any existing library including c-extensions like numpy and other data science tools.
Transcrypt looks pretty great for my purposes, thank you!
That 5 second loading time only happends once though.
Sadly, not true. It seems like even with cache on, it still takes 5 seconds for the JIT to load everything.
Agreed, wasm loading is supposed to be cached but in practice it doesn't seem to happen.