{"slug": "why-small-python", "title": "Why Small Python", "summary": "A project called Small Python, hosted at github.com/soasme/small-python, has built a lean Python interpreter in a single spy.h/spy.c pair of about 35,000 lines of code that runs in roughly 0.8x of CPython's time and uses a small amount of memory, according to its author. Small Python strips out the standard libraries except an optional sys module, so PyPI packages and uv do not work with it, and instead lets developers register host functions in Rust, Go or C; it also adds code metering so LLM-generated code can be aborted, paused or resumed, which the author says CPython would never have. The toolchain can compile Python together with Go/Rust/C, producing a mini Minecraft clone binary of less than 3MB, and the roadmap covers distributed sandboxing workers, coding agent integrations and tracking upstream Python.", "body_md": "# Why Small Python\n\nCPython is the official one; PyPy is a JIT. Jython is old. GraalPy needs the JVM. MicroPython is for chips. Pydantic Monty is… okay, the closest to what I need, but its subtle differences from CPython here and there are such a pain in the ass.\n\nI want something super lean with the least surprises. Only the core Python language features and builtin functions are needed. Whatever CPython produces, Small Python produces too. For other capabilities, you register functions in your host language. It should also be metered, so that when the runtime runs LLM-generated code, it can abort, pause, or resume.\n\n[Small Python](https://github.com/soasme/small-python) has a QuickJS-like architecture: one single `spy.h`/` spy.c` (35k LoC so far). I trimmed all the standard libraries away, leaving only `sys`, which can change the interpreter behavior (and it’s optional). So many PyPI packages, and uv, won’t work with Small Python as of now. But removing the libraries doesn’t mean it is weak. It opens a new door to a wider language ecosystem: you can totally build host functions in Rust/Go/C and link them into the program.\n\n[Code metering](https://www.julin.ai/2026/11/01/small-python-metering/) is something CPython would never have. If a piece of code reaches its budget, it should be halted. If the code is paused because a cloud worker was killed, the agent can resume it on another machine and keep executing. This is essential for a coding agent’s codemode to behave well, and Small Python is starting to support it. Since all executed Python code lives on the heap, with no recursive C, it’s safe to pause anywhere and resume later (on the roadmap 😄).\n\nThe performance outcome is amazing, though: it beats CPython’s speed (it runs in about 0.8x of CPython’s time) and only needs a tiny amount of memory.\n\nAnother feature I have always wanted over the past decades is compiling a Python app into a super small binary. None of the packaging tools can do that: you need to bundle Python, the packages, etc. Small Python can compile Python code together with Go/Rust/C. For example, a mini Minecraft clone built with the Small Python toolchain produces a binary of less than 3MB.\n\nThe roadmap going forward includes distributed sandboxing workers, coding agent integrations, tracking upstream Python, etc.\n\nWith all that said, small, fast, no surprises, and compilation are an unusual feature set in the Python world. And Small Python takes that tiny sweet spot.", "url": "https://wpnews.pro/news/why-small-python", "canonical_source": "https://julin.ai/2026/11/16/why-small-python/", "published_at": "2026-11-15 11:00:00+00:00", "updated_at": "2026-11-15 23:21:58.739848+00:00", "lang": "en", "topics": ["artificial-intelligence", "ai-agents", "ai-tools", "developer-tools"], "entities": ["Small Python", "CPython", "PyPy", "Jython", "GraalPy", "MicroPython", "Pydantic Monty", "QuickJS"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/why-small-python", "markdown": "https://wpnews.pro/news/why-small-python.md", "text": "https://wpnews.pro/news/why-small-python.txt", "jsonld": "https://wpnews.pro/news/why-small-python.jsonld"}}