whatisgithub

What is micropython-wasm?

simonw/micropython-wasm — explained in plain English

Analysis updated 2026-05-18

74PythonAudience · developerComplexity · 3/5LicenseSetup · easy

In one sentence

A Python package that runs small MicroPython code snippets inside a sandboxed WebAssembly container, with no file or network access unless explicitly allowed.

Mindmap

mindmap
  root((micropython-wasm))
    What it does
      Sandboxed MicroPython
      Runs in WebAssembly
      No file or network access
    Tech stack
      Python
      MicroPython
      Wasmtime
      WASI
    Use cases
      Run untrusted code safely
      One shot execution
      Persistent sessions
    Controls
      Memory limit
      Fuel budget
      Wall clock timeout

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Safely execute untrusted or AI-generated Python-like code snippets in an isolated sandbox.

USE CASE 2

Run one-shot MicroPython scripts from the command line or from a Python program.

USE CASE 3

Keep variables and functions alive across multiple code executions using a persistent session.

What is it built with?

PythonMicroPythonWebAssemblyWasmtimeWASI

How does it compare?

simonw/micropython-wasmltczding-gif/ref-downloadersomnusochi/vlm-autoyolo
Stars747474
LanguagePythonPythonPython
Setup difficultyeasymoderatehard
Complexity3/53/54/5
Audiencedeveloperresearcherdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Install from PyPI with pip, no external services or compiled dependencies needed to get started.

Apache 2.0 lets you use, modify, and distribute the project, including commercially, as long as you keep attribution notices.

So what is it?

This is a Python package that lets you run MicroPython, a lightweight Python variant designed for small devices, inside a locked-down WebAssembly container. The idea is to give you a safe place to execute untrusted code snippets: the sandboxed process has no access to your files or network unless you explicitly permit it. Install it from PyPI with a single pip command, then call it from the command line or import it into your own Python programs. There are three ways to run code. The simplest is a one-shot call that starts a fresh MicroPython process, executes your snippet, captures the output, and exits. Each call is fully independent, variables and imports do not carry over between calls. For cases where you want state to persist across several calls, a session class keeps a MicroPython interpreter alive in a background thread, so variables and functions defined in one call are still available in the next. A third option rebuilds state by replaying all previous successful snippets before each new one, avoiding the background thread at the cost of slightly more work per call. You can tune three resource limits: the maximum memory the container can use, a fuel budget that caps the total number of compute steps before the process is stopped, and a wall-clock timeout in seconds. A read-only folder from your host machine can optionally be exposed inside the container if the code needs to read input files. These controls mean that even if the code you run contains bugs or deliberate attempts to consume resources, it cannot escape the container or run indefinitely. The project is described as experimental in the README. It uses a custom MicroPython build targeting the WASI runtime standard, which is the portable WebAssembly interface for system calls. This is distinct from the browser-targeted or Node.js-targeted MicroPython builds that exist elsewhere. The underlying execution engine is the Wasmtime Python package, which handles the WebAssembly runtime. A command-line interface is also included for running MicroPython scripts or dropping into an interactive session without writing any Python of your own.

Copy-paste prompts

Prompt 1
How do I install and run a one-shot MicroPython snippet using this package's run() function?
Prompt 2
Explain the difference between MicroPythonSession and MicroPythonReplaySession in this project.
Prompt 3
How do I set memory, fuel, and wall-clock limits when running untrusted code with this sandbox?
Prompt 4
Write a Python script that uses MicroPythonSession to keep state across several code executions.

Frequently asked questions

What is micropython-wasm?

A Python package that runs small MicroPython code snippets inside a sandboxed WebAssembly container, with no file or network access unless explicitly allowed.

What language is micropython-wasm written in?

Mainly Python. The stack also includes Python, MicroPython, WebAssembly.

What license does micropython-wasm use?

Apache 2.0 lets you use, modify, and distribute the project, including commercially, as long as you keep attribution notices.

How hard is micropython-wasm to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is micropython-wasm for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.