{"slug": "i-built-a-python-c-transpiler-then-it-transpiled-itself", "title": "I built a Python -> C transpiler. Then it transpiled itself.", "summary": "A developer built Transpilatron, an AI agent that transpiles Python code into fully static C binaries, achieving speedups of up to 58x on benchmarks. The tool successfully transpiled its own source code into a working C binary, and can convert Flask apps into native C HTTP servers with no Python runtime. Transpilatron is designed for environments like initramfs and scratch containers where no interpreter is available.", "body_md": "A few weeks ago I needed to run Python scripts in initramfs — the tiny Linux environment that exists before your actual OS boots. No interpreter. No dynamic linker. Nothing.\n\nSo I built **Transpilatron**: an AI agent that takes Python code and produces a fully static C binary.\n\n```\nuvx transpilatron your_code.py\n```\n\nThat's it. No C knowledge required.\n\nFirst, does it actually work? I ran two tests:\n\n| Benchmark | Python | C | Speedup |\n|---|---|---|---|\n| Sieve of Eratosthenes (10M numbers) | 0.526s | 0.022s | 24x |\n| Selection sort (10K elements) | 1.963s | 0.033s | 58x |\n\nSame output. Verified on the same machine. The C binary is fully static — no runtime, no interpreter, no dependencies.\n\nThen I tried something more interesting. A 14-line Flask app:\n\n``` python\nfrom flask import Flask\n\napp = Flask(__name__)\n\n@app.route('/')\ndef hello():\n    return 'Hello from the webserver!'\n\n@app.route('/ping')\ndef ping():\n    return 'pong'\n\nif __name__ == '__main__':\n    app.run(host='0.0.0.0', port=8080)\n```\n\nOne command:\n\n```\nuvx transpilatron web.py\n```\n\nOutput: a native C HTTP server. No Flask. No Python runtime.\n\n``` bash\n$ curl http://localhost:8080/\nHello from the webserver!\n\n$ curl http://localhost:8080/ping\npong\n```\n\nVerified memory-safe by valgrind: 0 errors, 0 leaks.\n\nHere's where it gets weird.\n\nTranspilatron is written in Python. So I pointed it at its own source code:\n\n```\nuvx transpilatron src/transpilatron/agent.py\n```\n\nThe agent read its own Python source, wrote 400+ lines of C, fixed its own compiler errors autonomously, ran a memory audit, and produced a working binary.\n\n```\n$ ./out/agent --help\nUsage: ./agent [--minimal|--full] <entry_file>\n  --minimal  Use minimal mode: static linking, raw sockets only\n  --full     Use full mode (default): dynamic linking, libcurl, etc.\n\n$ ./out/agent examples/web.py\nThinking...\nI'll help you convert the Python project to C...\n```\n\n**A C binary, orchestrating an AI agent, transpiling Python to C.**\n\nValgrind result: 0 errors, 0 leaks.\n\nTranspilatron wraps the Poolside CLI (free) as its agentic backend. The agent:\n\n`-O3`\n\n| Mode | Linking | HTTP | Best for |\n|---|---|---|---|\n`--minimal` |\nStatic only | Raw BSD sockets | initramfs, scratch containers, embedded |\n`--full` |\nDynamic permitted | libcurl | Web apps, ML inference, general use |\n\n`--full`\n\nmode supports Flask/FastAPI → libmicrohttpd, torch/tensorflow → libtorch/TFLite, OpenCV, and more.\n\nNuitka bundles CPython. PyInstaller bundles CPython. Both produce 30MB+ binaries that require a Python runtime.\n\nTranspilatron strips CPython entirely. The output binary has no idea Python exists.\n\nThat's the only approach that works for initramfs, scratch containers, or embedded targets with no OS.\n\n```\nuvx transpilatron your_code.py\n```\n\nRequires only `uv`\n\n. Everything else (Poolside CLI, gcc, make, valgrind) is auto-installed on first run.\n\nGitHub: [NoodlixProject/transpilatron](https://github.com/NoodlixProject/transpilatron)\n\n*Transpilatron was originally built to compile boot scripts for Noodlix — a Python-only OS I'm building. That project is ongoing.*", "url": "https://wpnews.pro/news/i-built-a-python-c-transpiler-then-it-transpiled-itself", "canonical_source": "https://dev.to/jhi2/i-built-a-python-c-transpiler-then-it-transpiled-itself-3p8i", "published_at": "2026-06-20 15:54:24+00:00", "updated_at": "2026-06-20 16:06:45.732214+00:00", "lang": "en", "topics": ["developer-tools", "artificial-intelligence", "large-language-models"], "entities": ["Transpilatron", "Noodlix", "Poolside CLI", "Flask", "CPython", "Nuitka", "PyInstaller", "Valgrind"], "alternates": {"html": "https://wpnews.pro/news/i-built-a-python-c-transpiler-then-it-transpiled-itself", "markdown": "https://wpnews.pro/news/i-built-a-python-c-transpiler-then-it-transpiled-itself.md", "text": "https://wpnews.pro/news/i-built-a-python-c-transpiler-then-it-transpiled-itself.txt", "jsonld": "https://wpnews.pro/news/i-built-a-python-c-transpiler-then-it-transpiled-itself.jsonld"}}