Running Python code in a sandbox with MicroPython and WASM
simonwillison.net21 points by theanonymousone 3 hours ago
21 points by theanonymousone 3 hours ago
Hey simonw, if you're reading this, you should check out https://github.com/dbohdan/starlark-python. theanonymousone may want to check it out, too.
It's my project inspired by micro-javascript and Simon Willison's quest for sandboxed Python. Not only that, but I used the Claude Code transcript he published to generate a playbook that the porting agent then followed. I wrote up the port at https://dbohdan.com/starlark-python.
I thought about whether to port MicroPython, PocketPy, or Starlark to pure Python and ultimately stuck with Starlark because it was designed for untrusted code and had a conformance test suite. This looked about as optimized for agentic code as a problem could get. While Starlark is more restrictive, my needs for configuration and safe scripting are currently satisfied (see #users in the README).
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.
For me it is a tool I avail to an LLM so that it can provide correct answers to a certain category of questions, instead of hallucinating nonsense.
P.S. I was casually searching for "sandboxed Python" for an experiment I'm working on, and reached this article that was published "today". Very nice coincidence! Thanks.