Live data from Hacker News

PyScript: Run Python in your HTML

pyscript.net

31–40 of 71 posts

Re: PyScript: Run Python in your HTML

#31
post #20
post #3

I really really like this, but 4 MB zipped is a bit of a hard sell :/ I've had a need to deploy small ad-hoc HTML tools at work, though, and my Python is much better than my JS, so maybe it's worth it.

For one of the examples, I saw it coming down with pyscript.js - 1.1 MB, pyodide.asm data + wasm of 16 MB, and each python package as a separate wheel download (cool!), matplotlib of 6MB :)

All your megabytes are belong to us! Webassembly is the future!

Re: PyScript: Run Python in your HTML

#32

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 fe…

Just 5 seconds? Sign me up. Corporate web sites take 30+ to load already.. /s

Re: PyScript: Run Python in your HTML

#33
post #5

For some reason, I can't see this linked anywhere on the site, but there is an examples page: https://pyscript.net/examples/ (This was presented today as a pycon keynote talk!)

Thank you, I was searching on the front page and didn't find those example. Would be good to add this.

Re: PyScript: Run Python in your HTML

#34

Thank you for posting this. Of course it would be better if Chrome shipped with Python support, but this is a good effort. Does Wasm generally support other languages ?

wasm supports any language that compiles to wasm (or has its interpreter compiled to wasm). It's a bit like asking if "x86 assembly supports other languages"-- it supports whatever targets it!

Re: PyScript: Run Python in your HTML

#35
post #5

For some reason, I can't see this linked anywhere on the site, but there is an examples page: https://pyscript.net/examples/ (This was presented today as a pycon keynote talk!)

okay thought it wasn't working because it seems to take a long time for the spinner to go away. but I'm very impressed with the todo.py! This is what frontend should be and in 5 years or so I wouldn't be surprised to see python taking over. If only the initial payload for the python runner was smaller and if only browsers started supporting webassembly/python stack out of the box!!! from datetime import datetime as d…

> if only browsers started supporting webassembly/python stack out of the box!!

This seems highly unlikely. Each browser maker would have to have two teams now (one for JavaScript and one for Python). An additional language would add a new security/hacking vector. They would need to keep both languages at parity which would probably slow development and make testing much more complicated. Would JS and Python be able to both work on the same web page at the same time? What if both tried to interact with the same element at the same time? This is just thoughts off the top of my head. I’m sure the real issues would be much more complicated.

Re: PyScript: Run Python in your HTML

#36
post #27

Don't hate me for saying this, but I can imagine combining this with Electron and develop desktop apps with Python.

Isn’t the whole point of electron that people don’t want to learn a new language?

Asking these web devs turned desktop app developers to learn python is probably a bridge too far…

Re: PyScript: Run Python in your HTML

#37

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 fe…

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.)

Re: PyScript: Run Python in your HTML

#38

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 fe…

PyScript intent for using pyodide was usability with any existing library including c-extensions like numpy and other data science tools.

Re: PyScript: Run Python in your HTML

#40
post #27

Don't hate me for saying this, but I can imagine combining this with Electron and develop desktop apps with Python.

Isn’t the whole point of electron that people don’t want to learn a new language? Asking these web devs turned desktop app developers to learn python is probably a bridge too far…

No, the point is companies/devs want to one codebase to work on all 4 platforms. (Win, mac, linux, browser)
Post reply on HN