News for hackers. Stuff that matters.
Re:Python 3.11 in the Web Browser by mcintyre1994 on Saturday March 26, 2022 @05:41PM (#30815617)
I’m a big fan of Python in WASM! It really reduces the friction of playing around with things. Something I find pretty useful that I hacked together using it is https://pyground.vercel.app/ - I use it whenever I have a CSV or JSON file I want to do some poking around in using Python.

You can just drag and drop a file in, it’ll be imported in as the ‘data’ variable, and then you can run Python code/do matplotlib visualisations without installing anything.

Re:Python 3.11 in the Web Browser by discordance on Saturday March 26, 2022 @08:50PM (#30816713)
Re:Python 3.11 in the Web Browser by hackernewds on Saturday March 26, 2022 @11:46PM (#30817527)
Why use anything else when Jupyter is on WASM?
Re:Python 3.11 in the Web Browser by mcintyre1994 on Sunday March 27, 2022 @05:29AM (#30818943)
JupyterLite would probably be my go-to for working on a script or just trying out some Python or something like that. It looks like it'd be way less friction than getting Jupyter running locally, especially if you don’t use Python often.

Pyground is specifically written for a use case I wanted to optimise: to get data from a file on your local machine into a structured Python variable fast. I think with Jupyterlite you’d have to upload the file and then write your own code to read it/parse timestamps, which is just boilerplate. So if you're trying to do something like that and don't need anything else that JupyterLite offers then pyground might get you there faster. JupyterLite is way more flexible though.

Also you can use pyground to load the data, then do `import pickle; pickle.dumps(data)` in pyground, copy the output and then do `import pickle; data = pickle.loads(<copied output>)` in JupyterLite and you'll have the loaded data variable way faster than writing that code yourself and all the flexibility of JupyterLite :)

Re:Python 3.11 in the Web Browser by wishawa on Saturday March 26, 2022 @05:47PM (#30815652)
Have you seen Skulpt [1]? It doesn’t do matplotlib (or most other library) but it’s pure JS.

[1]: https://skulpt.org/

Re:Python 3.11 in the Web Browser by acbart on Sunday March 27, 2022 @12:17AM (#30817664)
MatPlotLib support in Skulpt for BlockPy [1]. Not complete, but workable for a lot of common graphs that I use in my CS1 course.

[1]: https://github.com/blockpy-edu/skulpt/blob/master/src/lib/ma...

Re:Python 3.11 in the Web Browser by mcintyre1994 on Saturday March 26, 2022 @06:03PM (#30815766)
Ah yep! I came across it a few years ago when I was chatting to the team at anvil.works, they were using it for their client side python. Looks really cool, really ambitious and impressive project.
Re:Python 3.11 in the Web Browser by rufugee on Saturday March 26, 2022 @07:07PM (#30816159)
Anvil is pretty cool...I spent a good bit of time experimenting with it. Unfortunately, it has some edges you hit quickly as an experienced developer which get in your way. However, for their target audience, which I infer to be skilled business folks who don't necessarily develop full time, it's awesome ;-)
Re:Python 3.11 in the Web Browser by tomatowurst on Saturday March 26, 2022 @08:43PM (#30816684)
interesting, is it possible to write some sort of frontend framework like solidjs with this? what would be the the performance like I wonder.

it would be really great if we could have full python/pip support in the browser but with some vetting done (just realized we don't have such thing in pip, other than relying on pip lockfiles and pipenv)

Re:Python 3.11 in the Web Browser by productceo on Saturday March 26, 2022 @09:24PM (#30816903)
Interesting! So I can write any Python code here in the web app, and the Python code will run locally on my client machine without sending any information to 3P web servers?
Re:Python 3.11 in the Web Browser by mcintyre1994 on Sunday March 27, 2022 @04:26AM (#30818674)
Yep, it’s all static with no server side and the Python all runs locally. The source is on GitHub: https://github.com/mcintyre94/pyground so you can run it locally or deploy it yourself if you’d like too. Any files you load always stay local too.

There are some limitations around what Python code you can run, there’s some details in the readme about those.

Re:Python 3.11 in the Web Browser by irisman on Saturday March 26, 2022 @07:00PM (#30816107)
Did you use tailwind css for that?
Re:Python 3.11 in the Web Browser by mcintyre1994 on Saturday March 26, 2022 @07:07PM (#30816157)
Yep, I think it might have some tailwind UI bits and pieces too. The source is on GitHub: https://github.com/mcintyre94/pyground