Pytra
Ultimate transpiler: converts Python to C++, Rust, C#, PowerShell, JavaScript, TypeScript, Dart, Go, Java, Swift, Kotlin, Ruby, Lua, Scala3, PHP, Nim, Julia, and Zig.
Install / Use
/learn @yaneurao/PytraREADME
Features
🐍 Python → native code in each target language
- 🌐 Transpiles to C++ / Rust / Go / Java / TS and many more
- 🧩 Preserves the original code structure almost entirely
- ⚡ Write in Python, generate high-performance code
- ✨ Simple Python subset input
- 🛠 Works with existing tools like VS Code out of the box
- 🔧 The transpiler itself is written in Python — easy to extend
- 🔁 Self-hosting capable — can transpile itself
Performance Comparison
Execution time of sample code written in Python versus execution time of the same code after transpilation. (Unit: seconds.) The Python column is the original code; PyPy is included for reference.
|No.|Description|<img alt="Python" src="https://img.shields.io/badge/-Python-3776AB?style=flat-square&logo=python&logoColor=white">|<img alt="PyPy" src="https://img.shields.io/badge/-PyPy-4B8BBE?style=flat-square">|<img alt="C++" src="https://img.shields.io/badge/-C%2B%2B-00599C?style=flat-square&logo=cplusplus&logoColor=white">|<img alt="Rust" src="https://img.shields.io/badge/-Rust-F6B73C?style=flat-square&logo=rust&logoColor=black">|<img alt="C%23" src="https://img.shields.io/badge/-C%23-239120?style=flat-square&logo=dotnet&logoColor=white">|<img alt="JS" src="https://img.shields.io/badge/-JS-F7DF1E?style=flat-square&logo=javascript&logoColor=black">| |-|-|-:|-:|-:|-:|-:|-:| |06 |Julia set parameter sweep (GIF)|9.627|0.507|0.546|0.407|0.329|0.626| |16 |Glass sculpture chaos rotation (GIF)|6.847|0.606|0.277|0.246|1.220|0.650|
Full data for all languages and all samples → Sample page
<table><tr> <td valign="top" width="50%">
- Full source: sample/py/06_julia_parameter_sweep.py
C++ | Rust | C# | JS | TS | Dart | Go | Java | Swift | Kotlin | Ruby | Lua | Scala3 | PHP | Julia
</details> </td> <td valign="top" width="50%">
- Full source: sample/py/16_glass_sculpture_chaos.py
C++ | Rust | C# | JS | TS | Dart | Go | Java | Swift | Kotlin | Ruby | Lua | Scala3 | PHP | Julia
</details> </td> </tr></table>Python vs C++ vs Rust vs Pytra
Legend: ✅ = Good / 🔶 = Partial / limited / ❌ = Not supported / difficult
| Aspect | |
|
|
|
|-|-|-|-|-|
| Syntax | ✅ Simple | ❌ Complex | 🔶 Ownership/<br>lifetimes | ✅ Same as Python |
| Type safety | ❌ Dynamic | ✅ Static | ✅ Static | ✅ Static<br>(Python-style annotations) |
| Execution speed | ❌ Slow | ✅ Fast | ✅ Fast | ✅ Fast<br>(depends on target) |
| Memory management | ✅ GC<br>(easy but heavy) | ❌ Manual/<br>shared_ptr | 🔶 Ownership<br>(safe but hard) | ✅ RC-based<br>automatic |
| Integer types | 🔶 Arbitrary precision only | ✅ int8–64 | ✅ i8–i64 | ✅ int8–64 |
| float | 🔶 64-bit only | ✅ 32/64-bit | ✅ f32/f64 | ✅ 32/64-bit |
| Build | ✅ Not needed | ❌ CMake etc. | 🔶 cargo | ✅
./pytra<br>--build --run |
| Multi-language output | ❌ | ❌ | ❌ | ✅ 18 languages |
| Optimization | ❌ Limited | ✅ Rich | ✅ Rich | ✅ Leverages target |
| Distribution | 🔶 Requires runtime | ✅ Binary | ✅ Binary | ✅ Language-native |
| Single inheritance | ✅ | ✅ | ❌ traits only | ✅ |
| Multiple inheritance | ✅ | 🔶 Complex | ❌ | ❌ |
| Mix-in | ✅ | 🔶 CRTP etc. | ❌ | ✅ |
| Trait/<br>Interface | 🔶 Protocol | 🔶 virtual base | ✅ Native | ✅ @trait |
| Exception handling | ✅ | ✅ | ❌ Result/panic | ✅ All languages |
| Templates/<br>Generics | ❌ | 🔶 Cryptic errors | ✅ | ✅ @template |
| Selfhost | ❌ | ❌ | ❌ | ✅ |
<a id="read-the-docs"></a>
Read the Docs
| | |
|
|---|---|---|
| Getting started | Tutorial | チュートリアル |
| Guide | Guides | ガイド |
| Specification | Spec index | 仕様書 |
| Progress | Project Progress | プロジェクト進捗 |
Changelog
2026-04-07 — Lint down to 149 / 14 languages at 10/10 PASS (697→149). PyFile abolished, IOBase hierarchy in
built_in/io.py. Emitter guide §12.7. Cross-language PyFile coupling removal. Go/Rust/C#/PHP/Ruby/Lua emitter guide alignment.
2026-04-06 — With statement via
__enter__/__exit__protocol (CommonRenderer try/finally + hoist). 2 with fixtures added. Parity FAIL keeps work dir. TS/JS shim cleanup complete. Dart emitter guide compliance. JVM major progress (Scala/Kotlin emitters). .east* removed from git.
2026-04-05 — containers.py
mut[T]annotations formeta.mutates_receiver. C++ method name hardcode removed. mapping.json FQCN key unification. Toolchain rename complete.
2026-04-04 — 23 Python method name hardcode patterns in lint. All-skip parity now FAIL. callable_optional_none fixture. Emitter guide §12.6 callable mapping + §14.1 lint docs.
[Full changelog](docs/en/cha
