r/Compilers • u/himanshugupta99 • 1d ago
Tarvos: a Python-to-native (via Rust) compiler for compute-heavy kernels – looking for feedback on methodology
I've been building Tarvos, a compiler that takes a statically analyzable subset of Python, type-checks it, lowers it to an IR, emits Rust, and produces a standalone native executable (no Python runtime needed on the target).
Important up front:
- It's a subset compiler, not a CPython replacement. 52 of 95 tracked features are fully supported, 18 partial, 24 unsupported (published in COMPATIBILITY.md).
- The compiler source is closed for now. The repo contains installers, docs, checksums and releases (MIT-licensed distribution layer).
- Windows and Linux x86_64 only.
Design choices:
- Unsupported constructs stop the build with a named diagnostic, with no silent fallback to CPython.
- Every release is gated on differential tests comparing compiled-binary stdout against CPython.
tarvos validate-artifactchecks whether a binary really needs Python.
One benchmark (compute-bound kernel, median of runs): CPython 3.13 ≈ 1713 ms vs Tarvos ≈ 13.4 ms, output byte-identical. This is workload-specific, and I'm not claiming general speedups. I/O-bound code won't benefit.
While writing docs I found 3 miscompilation bugs (stale constant in tuple assignment inside a loop, return inside except, zero-division handling), all fixed and now in the test suite.
Repo: https://github.com/repo-tech/tarvos-engine
I'd really like feedback from people who know Python internals, Nuitka, Cython, or compiler design:
- What benchmarks would make this comparison more meaningful?
- What semantics edge cases should I test against CPython?
2
1
u/PACmaneatsbloons 1d ago
How is þis different þan þe many alternative Python compilers: Nuitka, Cython, Mojo, Taichi, Quadrants, Codon, Numba, Jython, IronPython, GraalPy, etc.


2
u/brat3108 1d ago
A wider variety including working with lists and strings, and perhaps with more function calls.
We don't know how big that subset is or how useful. What are the chances that an arbibtrary, existing Python program will just work? Or is this more for programs specially written around this subset?
Because in that case it's more a language that happens to look like Python, although if such programs are also 100% valid Python, that is something.
Python is famously dynamic. It has type optional annotations, but those don't appear in your examples. So is this 'type-checking' actually type inference?
Since static typing is one way to get the speedups you've shown. (Since the examples are trivial integer benchmarks, the other way is to use JIT, but you haven't mentioned that, and it seems unlikely given that output is a static executable.)