Skip to content

yaneurao/Pytra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5,567 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Read in Japanese

Pytra Code Alchemist

Pytra

Python is Pytra's source language. Pytra transpiles that code into multiple target languages.

Β· Supported Backends Β·

C++ Rust C# PowerShell JS TS Dart Go Java
Swift Kotlin Ruby Lua Scala3 PHP Nim Julia Zig

Features of Pytra

🐍 Python β†’ Native code in each target language

  • 🌐 Transpiles to C++, Rust, Go, Java, TS, and many more
  • 🧩 Preserves the original program structure almost as-is
  • ⚑ Generates high-performance code even when you write in Python
  • ✨ Uses a simple Python subset
  • πŸ›  Works with existing tools such as VS Code
  • πŸ”§ The core is also written in Python, so it is easy to extend
  • πŸ” Supports self-hosting

Runtime Performance Comparison

These are execution times for sample programs written in Python and for their transpiled source code. Unit: seconds. In the table, Python is the original implementation and PyPy is included as a reference.

No. Workload Python PyPy C++ Rust C# JS
06 Julia-set parameter sweep (GIF) 9.627 0.507 0.546 0.407 0.329 0.626
16 Chaotic rotation of a glass sculpture (GIF) 6.847 0.606 0.277 0.246 1.220 0.650

Full data for all languages and all samples: Sample page

06_julia_parameter_sweep

Sample code: 06_julia_parameter_sweep.py
Transpiled code in each language

C++ | Rust | C# | JS | TS | Dart | Go | Java | Swift | Kotlin | Ruby | Lua | Scala3 | PHP | Julia

16_glass_sculpture_chaos

Sample code: 16_glass_sculpture_chaos.py
Transpiled code in each language

C++ | Rust | C# | JS | TS | Dart | Go | Java | Swift | Kotlin | Ruby | Lua | Scala3 | PHP | Julia

Python vs Pytra

Aspect Python Pytra
Execution Runs on the Python interpreter Runs in each backend language
Integers Arbitrary precision int64, uint64, ..., int8, uint8
Floating point 64-bit 64-bit / 32-bit
Runtime speed x1 x10 to x100 when transpiled to C++ or Rust
Backend optimization Limited Extensive
Multi-language deployment ❌ βœ…
Typing Dynamic typing Static typing
Bounds checks Always enabled Customizable
Platform integration Python-centric Fits each language's SDKs and tools
Distribution Requires Python runtime Uses each language's native distribution model
Multiple inheritance βœ… ❌, single inheritance only
Mix-ins βœ… βœ…
Self-hosting ❌ βœ…

⚠ This project is still under active development and may be far from practical use. Review the sample code and use it at your own risk.

Read the Docs

Changelog

2026-03-26 - Pipeline redesign completed. All six stages of the pipeline (parse -> resolve -> compile -> optimize -> link -> emit) now work end to end. The Go backend has been migrated to the new pipeline.

2026-03-25 - All P0 tasks completed. Reorganized the test/ directory. Go emitter and runtime reached parity on all 18 samples.

2026-03-24 - Started the pipeline redesign. Added toolchain2/, implemented pytra-cli2, and defined the EAST1/EAST2 specifications.

Full history: docs/en/changelog.md

License

Apache License 2.0

About

Ultimate transpiler: converts Python to C++, Rust, C#, PowerShell, JavaScript, TypeScript, Dart, Go, Java, Swift, Kotlin, Ruby, Lua, Scala3, PHP, Nim, Julia, and Zig.

Topics

Resources

License

Stars

Watchers

Forks

Contributors