Live data from Hacker News

Running Python code in a sandbox with MicroPython and WASM

simonwillison.net

11–20 of 46 posts

Re: Running Python code in a sandbox with MicroPython and WASM

#13

If you're interested in not reinventing the sandbox for LLMs, consider Judge0: https://judge0.com/ I have absolutely no relation to the project except for the fact that I went to the same Uni as the creator.

That one looks pretty good - it's been around since 2016, I'm surprise I haven't encountered it before.

It's not quite right for what I'm after because you can't just "pip install" it on multiple platforms.

Re: Running Python code in a sandbox with MicroPython and WASM

#14

What’s your experience with Monty? Been looking at it for one of our environments and it seems very promising.

I've tried it out a bit - it does look solid and it has a good team behind it.

It's a subset of Python though (much more so than MicroPython), which is fine for LLMs since they can easily work around any limitations but does mean you can't use a lot of existing Python code with it. I hope they implement classes soon!

I'm also a little bit nervous about the safety. It's a fresh implementation in Rust, which means plenty of possibilities for edge case security bugs. The thing I like about WebAssembly is that there's a robust, well tested sandbox already - better for defense in depth.

I certainly wouldn't bet against Monty though! It may well prove itself to be a great solution for this.

Re: Running Python code in a sandbox with MicroPython and WASM

#15

Super tangential comment but glad to see I'm not the only one that send typos to sessions and still get good results. Was reading your https://chatgpt.com/share/6a1e2a5c-58b8-8328-ba1c-0e6aadb0a0... and noticed the "my on Python tools" instead of "my own Python tools" (apologies for the grammar police) This stuff always gets me anxious for no reason because of the underlying tokenizer and prediction stochastic parrot…

Yeah I'm very loose with my prompting now - I can usually tell from the reasoning traces if it correctly interpreted any typos.

If it looks like it didn't I hit "stop" and then edit and resubmit my prompt.

Re: Running Python code in a sandbox with MicroPython and WASM

#16
post #3

I am trying to think of a use case for this. I was thinking the client side WASM version would be useful as a platform for beginners to practice a subset of Python in. I can't really think of any good WASI use cases.

I've had lots of fun with WASM Python in the browser - a few of my experiments with that are:

- https://lite.datasette.io - my Datasette app in a browser

- https://simonw.github.io/research/pyodide-asgi-browser/datas... is a new, improved version of that using Service Workers that's still a little experimental - notes here: https://simonwillison.net/2026/May/30/pyodide-asgi-browser/

- https://tools.simonwillison.net/micropython runs a MicroPython playground in the browser via WebAssembly

My use-cases for server-side WASM Python are described here: https://simonwillison.net/2026/Jun/6/micropython-in-a-sandbo... - basically I want to offer end-user customization features that run custom code without buggy or malicious code crashing my app or leaking their data.

Re: Running Python code in a sandbox with MicroPython and WASM

#17
post #3

I am trying to think of a use case for this. I was thinking the client side WASM version would be useful as a platform for beginners to practice a subset of Python in. I can't really think of any good WASI use cases.

Running arbitrary untrusted code safely is pretty easy nowadays, so long as the code is written in Javascript and you want to run it in a browser. It's only a little harder if the code is written in another language but targets WASM and browser APIs, or if you want to run your WASM inside of NodeJS, and there's even good support for running Python in a browser or Node. Once you get away from running in a JS environme…

I've actually found it pretty hard in a browser as well - if you want to run untrusted code without it breaking your app or stealing cookies etc.

I've been doing a bunch of work recently with iframe sandbox combined with CSP which appears to be a robust way to do this.

Re: Running Python code in a sandbox with MicroPython and WASM

#19
post #18

Is this the place to look at if you want to play around with a live demo: https://tools.simonwillison.net/micropython ?

No that's a different demo - that one is running MicroPython WASM directly in the browser.

I have a live demo with datasette-agent-micropython running at https://agent.datasette.io - you need to sign in with GitHub to try it.

Re: Running Python code in a sandbox with MicroPython and WASM

#20

If you're interested in not reinventing the sandbox for LLMs, consider Judge0: https://judge0.com/ I have absolutely no relation to the project except for the fact that I went to the same Uni as the creator.

This looks like something I can use for a project I'm working on. Thanks
Post reply on HN