5 ms·
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], a
by eatonphil 5y 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/src/App.svelte#L15 https://github.com/pyscript/pyscript/blob/main/pyscriptjs/sr...
[1] https://github.com/pyodide/pyodide https://github.com/pyodide/pyodide
[2] https://github.com/plasticityai/coldbrew https://github.com/plasticityai/coldbrew
[3] https://github.com/brython-dev/brython https://github.com/brython-dev/brython
- worewood 5y agoJust 5 seconds? Sign me up. Corporate web sites take 30+ to load already.. /s
- meredydd 5y agoThere 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 https://anvil.works/blog/python-in-the-browser-talk (We chose one of the Python-to-JS compilers, https://skulpt.org 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.)
- rmbyrro 5y agoOne downside with python-to-js compilers is losing easiness and speed to debug issues, which is one of the strongest points for using Python.
- eatonphil 5y agoIt also requires a server somewhere for dynamic input (i.e. Browser based notebooks).
- pjmlp 5y agoAnd before all of those, 20 years ago, ActiveState had a Python ActiveX extension (in addition to Perl and TCL).
- nacs 5y agoJust the word "ActiveX" brings about nightmares.
- nhumrich 5y agoPyScript intent for using pyodide was usability with any existing library including c-extensions like numpy and other data science tools.
- manjana 5y agoThat 5 second loading time only happends once though.
- nhumrich 5y agoSadly, not true. It seems like even with cache on, it still takes 5 seconds for the JIT to load everything.
- hoodchatham 5y agoAgreed, wasm loading is supposed to be cached but in practice it doesn't seem to happen.
- stavros 5y agoTranscrypt looks pretty great for my purposes, thank you!