Running Python code in a sandbox with MicroPython and WebAssembly
By
Simon Willison
2d ago· 9 min readenInsight
100/100
Golden Brown
Bagelometer↗
Pulled from the oven just right. Trustworthy, fact-dense, deeply satisfying.
Score100TypeanalysisSentimentpositive
Summary
The article describes the author's experimentation with running Python code in a sandbox environment using MicroPython compiled to WebAssembly (WASM). The author has released an alpha package called micropython-wasm and is using it for a code execution sandbox plugin for Datasette Agent. The piece discusses the motivation behind sandboxing (plugin extensibility for projects like Datasette, LLM, and sqlite-utils), the technical approach of using MicroPython compiled to WASM for safe code execution, and the characteristics that make this approach promising compared to previous attempts.
Key quotes
· 2 pulledI've been experimenting with different approaches to running code in a sandbox for several years now, but my latest attempt feels like it might finally have all of the characteristics I've been looking for.
I absolutely love plugins as a mechanism for extending software. A carefully designed plugin system can transform a good tool into an incredible platform.
I’ve been experimenting with different approaches to running code in a sandbox for several years now, but my latest attempt feels like it might finally have all of the characteristics …
