Python is the worst language to script anything inside a markup language that does not need to be structured like Python (HTML). So yeah, a good experiment, but unfortunately it is doomed to fail.
PyScript: Run Python in your HTML
61–70 of 71 posts
Re: PyScript: Run Python in your HTML
#62This 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 fe…
That 5 second loading time only happends once though.
Re: PyScript: Run Python in your HTML
#63Re: PyScript: Run Python in your HTML
#64Don't hate me for saying this, but I can imagine combining this with Electron and develop desktop apps with Python.
Re: PyScript: Run Python in your HTML
#65Re: PyScript: Run Python in your HTML
#66Earlier quoted context omitted.
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.
Re: PyScript: Run Python in your HTML
#67This is awesome and has so much potential! Regarding the size of the download, I know there is ongoing work in the Pyodide project to create a much smaller python runtime that will help tremendously. Also, the script will be cached once you download it once. EDIT: Also, you don't need NPM or anything locally to run these
But some other low hanging fruit include unvendoring the special encodings for Asian languages (hopefully everyone uses utf8), the decimal library, and the xml library which are all quite large and only occasionally used.
Re: PyScript: Run Python in your HTML
#68Based on the responses, I assume this is a silly question, but why? Why would I want to run Python in HTML? Does Python have some libraries that JS is missing? (I could think of AI/ML libs) The examples [1] seem so slow in my browser (Firefox on an Intel-based MBP) that they are borderline unusable for me (and some of them just straight out don't load within 60 seconds, like the Bokeh, at which point I give up). [1]…
This isn't good for most web use cases but there are some major new use cases that it enables.
Pyodide is in Python documentation all over the place, for instance on https://numpy.org/
Python has many libraries that JS is missing. Particularly the scientific computing ecosystem has a lot of very well supported Python packages but fewer JavaScript packages. They also can benefit a lot from connection to a UI.
Two key use cases for this stuff are Python education and scientific computing. Students have a hard time installing Python locally. Generally scientists want to share their results broadly, but they probably did their analysis in Python.
Here's another example of a good use case: https://www.socialfinance.org.uk/blogs/analysing-sensitive-d...
Re: PyScript: Run Python in your HTML
#69Based on the responses, I assume this is a silly question, but why? Why would I want to run Python in HTML? Does Python have some libraries that JS is missing? (I could think of AI/ML libs) The examples [1] seem so slow in my browser (Firefox on an Intel-based MBP) that they are borderline unusable for me (and some of them just straight out don't load within 60 seconds, like the Bokeh, at which point I give up). [1]…
> Why? This isn't good for most web use cases but there are some major new use cases that it enables. Pyodide is in Python documentation all over the place, for instance on https://numpy.org/ Python has many libraries that JS is missing. Particularly the scientific computing ecosystem has a lot of very well supported Python packages but fewer JavaScript packages. They also can benefit a lot from connection to a UI. T…
Re: PyScript: Run Python in your HTML
#70Based on the responses, I assume this is a silly question, but why? Why would I want to run Python in HTML? Does Python have some libraries that JS is missing? (I could think of AI/ML libs) The examples [1] seem so slow in my browser (Firefox on an Intel-based MBP) that they are borderline unusable for me (and some of them just straight out don't load within 60 seconds, like the Bokeh, at which point I give up). [1]…
If you already have a lot of domain logic in Python for your backend, that would make it easier to write a frontend living in the same codebase. (For example, imagine a framework for autogenerating forms for your Django models; this already exists server-side, but native client-side Python would give you more options. And if your framework owns both the client and server, it could autogenerate the API so you don’t ev…