4 ms·
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
by mcintyre1994 5y ago
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/ 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.
- wishawa 5y agoHave you seen Skulpt [1]? It doesn’t do matplotlib (or most other library) but it’s pure JS. [1]: https://skulpt.org/ https://skulpt.org/
- mcintyre1994 5y agoAh 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.
- rufugee 5y agoAnvil 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 ;-)
- tomatowurst 5y agointeresting, 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)
- acbart 5y agoMatPlotLib 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/matplotlib/pyplot/__init__.js https://github.com/blockpy-edu/skulpt/blob/master/src/lib/ma...
- irisman 5y agoDid you use tailwind css for that?
- mcintyre1994 5y agoYep, I think it might have some tailwind UI bits and pieces too. The source is on GitHub: https://github.com/mcintyre94/pyground https://github.com/mcintyre94/pyground
- discordance 5y agoJupyter in WASM is a thing too: https://blog.jupyter.org/jupyterlite-jupyter-%EF%B8%8F-webassembly-%EF%B8%8F-python-f6e2e41ab3fa https://blog.jupyter.org/jupyterlite-jupyter-%EF%B8%8F-webas...
- hackernewds 5y agoWhy use anything else when Jupyter is on WASM?
- mcintyre1994 5y agoJupyterLite 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 :)
- productceo 5y agoInteresting! 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?
- mcintyre1994 5y agoYep, it’s all static with no server side and the Python all runs locally. The source is on GitHub: https://github.com/mcintyre94/pyground 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.