PyTurbo V3
Python 3.10 → C99 transpiler with CPython API and DCE.
Optimization method: all you can make to C99; the rest through CPython API.
Author: Suleiman License: Apache 2.0 Copyright © Suleiman 2026
Quick start
python pyturbo.py transpile hello.py -o hello.c -v
Output:
hello.c— C99 + inline CPython declarations (~5 KB)hello.h— function prototypeshello.manifest.json— full analysis report
Compile:
gcc -std=c99 hello.c -lpython3.10 -o hello
./hello
Features
C99 where possible
- numbers →
double - arithmetic → native
+ - * / for i in range(n)→for (double i = 0; i < n; i += 1)+=,-=,*=, ... → nativeprint(x, y)→printf("%g %g\n", x, y)- numeric function parameters → unboxed to
double - numeric return values → boxed via
PyFloat_FromDouble
CPython API fallback
- strings, lists, tuples, dicts
- imports, module calls
- classes (via
type()) - exceptions
- lambdas
DCE for Python.h
- reads
Python.hfrom the system - extracts only the used prototypes (~15 of ~1800)
- inlines them into the
.cfile - no
#include <Python.h> - no
-Iflag needed - portable
.c
DCE for pythonXY.dll (Windows)
With --min-dll:
- detects the running Python version (310, 311, 312, 313, ...)
- finds
pythonXY.dll - produces a minimal
pythonXY-dce.dll - generates
pythonXY-dce.lib - adds
#pragma comment(lib, "pythonXY-dce.lib")to the.c
Then:
cl hello.c # MSVC auto-links the DCE library
Commands
pyturbo transpile <file.py> [-o out.c] [-v]
[--min-dll] [--cpython-src PATH]
pyturbo analyze <file.py>
pyturbo infer <file.py>
pyturbo tokens <file.py>
pyturbo version
pyturbo help
Example
import math
def sum_squares(n):
total = 0
for i in range(n):
total += i * i
return total
def main():
r = sum_squares(100)
print("Result:", r)
print("Sqrt:", math.sqrt(r))
main()
Generated C (excerpt)
PyObject* py_user_sum_squares(PyObject* py_n) {
double py_n_v = PyFloat_AsDouble(py_n);
double py_total = (double)((0L));
for (double py_i = (double)((0));
py_i < (double)(py_n_v);
py_i += (double)((1))) {
py_total += py_i * py_i;
}
return PyFloat_FromDouble(py_total);
}
PyObject* py_user_main(void) {
PyObject* py_r = py_user_sum_squares(PyLong_FromLong(100L));
double py_r_v = PyFloat_AsDouble(py_r);
printf("Result: %g\n", py_r_v);
PyObject* _m = PyImport_ImportModule("math");
PyObject* _f = PyObject_GetAttrString(_m, "sqrt");
PyObject* _t = PyObject_Vectorcall(_f, &py_r, 1, NULL);
double _t_v = PyFloat_AsDouble(_t);
printf("Sqrt: %g\n", _t_v);
Py_INCREF(Py_None);
return Py_None;
}
Size
| Feature | PyTurbo V3 | Cython | Nuitka |
|---|---|---|---|
| Input | .py | .pyx | .py |
| Annotations | not needed | needed | not needed |
| Output | .c | .c | .c/.exe |
.c size |
~5 KB | ~500 KB | ~1 MB |
| Binary | ~50 KB | ~1 MB | ~5 MB |
| Dependencies | 0 (CPython) | 3 | 5 |
| Python.h | inlined | #include |
#include |
| DLL DCE (Windows) | yes | no | no |
| Works on Android | yes | no | no |
| Speed (numeric) | ~50× | ~50× | ~1.3× |
Comparison
PyTurbo vs Cython
Cython requires .pyx syntax with cdef, cpdef.
PyTurbo accepts pure Python and infers types automatically.
PyTurbo vs Nuitka
Nuitka compiles for packaging (.exe).
PyTurbo focuses on generating minimal C with DCE.
DCE
Cython and Nuitka both require #include <Python.h> and pull
in all ~1800 prototypes.
PyTurbo removes unused declarations and inlines only the needed
~15 prototypes directly into the .c file.
Platform support
- Linux ✅
- macOS ✅
- Android (Termux, Pydroid3) ✅
- Windows ✅ (with
--min-dllfor DLL DCE)
License
Apache License 2.0. See LICENSE.
Metadata
Release files for pyturbo-v3 3.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyturbo_v3-3.0.1.tar.gz | 36.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyturbo_v3-3.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 75.8 kB
Release files / pyturbo_v3-3.0.1.tar.gz
| Download URL | pyturbo_v3-3.0.1.tar.gz |
|---|---|
| Size | 36.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2fbc0f375951fcacbc49106b5fe137fc6972ca413ee380cddc9cc2518ae25da2
|
|
BLAKE2b-256 checksum How to use checksums |
60bf56b8727a94b74d90c3eb27c97ccf26a54e005322e0d9fb116b6d4e21503c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Release files / pyturbo_v3-3.0.1-py3-none-any.whl
| Download URL | pyturbo_v3-3.0.1-py3-none-any.whl |
|---|---|
| Size | 39.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4ca0e38f34a4f499420d4d329bec014e469ca633f9c8f06fe6a69f823a2971d3
|
|
BLAKE2b-256 checksum How to use checksums |
b3727e248b51f413734414f5ce965b4da49cb25247e9d845eb748ade0d1878b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|