Small Python: A High-Performance C11 Interpreter
An embeddable Python engine designed for rapid execution and minimal binary footprints.
1Core Architecture Overview
Small Python is an embeddable engine written in C11, functioning similarly to QuickJS for JavaScript. It implements the core Python language features and built-ins without including the standard library. By excluding Lib/ and focusing on sys/gc, the interpreter maintains a lightweight footprint suitable for integration into diverse host environments and projects.
2Host Injection Mechanism
The absence of a standard library is mitigated by host-injected modules, allowing developers to leverage external ecosystems directly within Python syntax. Users can integrate Rust crates like Axum or Serde, or utilize Raylib for game development. This design choice enables Python to act as a scripting layer for high-performance native codebases.
3Performance and Benchmarking
While Small Python lacks a JIT compiler and does not match PyPy speeds, it consistently outperforms standard CPython in most benchmarked scenarios. The project prioritizes execution speed while maintaining a compact size. Developers can install the engine via pip, npm, crates, or go, ensuring broad compatibility across multiple programming language ecosystems.
4Binary Size Efficiency
Small Python offers a significant advantage in binary size compared to traditional tools like PyInstaller. A complete PONG game built with Raylib and this engine occupies approximately 2MB. This efficiency makes it an ideal choice for resource-constrained applications where minimizing the final executable size is a primary technical requirement for deployment.
5Robust Testing Framework
The project utilizes a comprehensive suite of testing tools, including unittest, fuzzing, sanitizers, and benchmarks. It also incorporates TLA+ specifications to ensure logical correctness. Despite being implemented in C, the developer reports zero segmentation faults to date, demonstrating a high level of stability achieved within a very short development timeframe.
6Development and Tooling
The entire engine was developed over a single week, heavily utilizing a long-running Claude Code session with Opus 5.5. This rapid development approach highlights the efficacy of AI-assisted coding in architecting complex systems like language interpreters. The project is currently hosted on GitHub, serving as an open-source resource for developers.
7Operational Safety Modes
The engine recommends a worker mode for execution, which isolates processes to contain potential issues within a subprocess. This architecture prevents runtime errors from crashing the main host application. By running code in a contained environment, developers gain an extra layer of security and stability when embedding Python scripts into larger systems.
8Future Roadmap for Agents
The roadmap focuses on agent-specific features, including snapshot and resume capabilities for durable sessions. Future updates will introduce policy declarations to prevent agents from executing harmful actions. These enhancements aim to position Small Python as a reliable, secure runtime environment for autonomous agents interacting with complex, long-running software systems.
Original article: Hacker News: Show HN — Small Python: A High-Performance C11 Interpreter