3 ms·
Unlike brython, pyodide or coldbrew you'll need a server to run the transcrypt program to get JavaScript from your Python. I use pyodide at the moment in datas
by eatonphil 5y ago
Unlike brython, pyodide or coldbrew you'll need a server to run the transcrypt program to get JavaScript from your Python.
I use pyodide at the moment in datastation [0] to provide an in-browser-memory demo environment. It means that environment is completely free other than static hosting costs while you get a nice (demo) computational notebook in your browser.
And while brython only implements a subset of Python and breaks some things like dict access for JavaScript interop, pyodide and coldbrew are complete cpython environments just running on wasm through emscripten.
The biggest issue with these binaries on wasm is that they take forever to load each time you come to the app. It takes like 20-30s to load. That's a pretty bad experience for my use case.
So I'm still testing every implementation I see out to find the right combo of fast load time and most pythonic implementation.
[0] https://github.com/multiprocessio/datastation https://github.com/multiprocessio/datastation
- guipsp 5y agoYou don't need a server, you just need to transpile beforehand.
- eatonphil 5y agoSure I meant that when used in prod you'd probably compile your Python to JavaScript on a (CI) server and/or if you wanted to dynamically run Python in the browser using Transcrypt you'd have to send the code to a server to be translated before you could run the resulting code in the browser. This all sounds pedantic but it's because not all "python in browser" implementations work like this.
- CivBase 5y agoOne approach I've still never seen is native browser support for Python - something like what Google's Dart team did with Dartium. Of course that means your site would be inaccessible to anyone with a normal browser so you couldn't run it in production... but were you really ever going to run something like this in a production environment anyways?
- dec0dedab0de 5y agoThat would be Brython. It's a Python interpreter and part of the standard library written in javascript. Along with some dom manipulation libraries.
- CivBase 5y agoI don't think that's true. https://brython.info/static_tutorial/en/index.html https://brython.info/static_tutorial/en/index.html > In the <head> zone we load the script brython.js : it is the Brython engine, the program that will find and execute the Python scripts included in the page. It looks like Brython works by embedding a Python interpreter into the page as Javascript. That's 5 MB if you include the standard library - almost 800 KB for just the interpreter. Not to mention the computational overhead of running an interpreter in an interpreter.
- dec0dedab0de 5y agoI did say it was an interpreter written in JS, but I had misunderstood what you were saying. I think Grail could do what you were talking about, but it never got any traction. I also vaguely remember there being a python plugin floating around back in the day, kind of like flash, but I can't find any reference to it.
- eesmith 5y agoFrom back when (non-avian) dinosaurs roamed the world - "Grail is an extensible Internet browser written entirely in the interpreted object-oriented programming language Python", available at http://grail.sourceforge.net/ http://grail.sourceforge.net/ > Grail lets you download Python programs that execute inside Grail on your local machine. These little applications ("applets") can do things like display animations, interact with the user in new ways, even create additional menus that pop up dialogs if you like.