Depyler
Energy-efficient Python-to-Rust transpiler with progressive verification capabilities. Transform Python code into safe, performant Rust while reducing energy consumption by 75-85%. Built with zero tolerance for technical debt and extreme quality standards.
π Installation
Install depyler
using one of the following methods:
-
From Crates.io (Recommended):
-
From Source:
-
From GitHub Releases: Pre-built binaries are available on the releases page.
Requirements
- Rust: 1.83.0 or later
- Python: 3.8+ (for test validation)
π Getting Started
Quick Start
# Transpile a Python file
# Analyze code complexity before transpilation
# Run with verification
# Interactive mode with AI suggestions
Using as a Library
Add to your Cargo.toml
:
[]
= "0.3.2"
Basic usage:
use ;
Key Features
π Core Transpilation
- Python AST to HIR - High-level intermediate representation for safe transformations
- Type Inference - Smart type analysis with annotation support
- Memory Safety - Automatic ownership and borrowing inference
- Direct Rules Engine - Pattern-based Python-to-Rust transformations
β‘ Performance & Efficiency
- Energy Reduction - 75-85% lower energy consumption vs Python
- Binary Optimization - Compile with LTO, strip, and
panic=abort
- Zero-Copy Strings - Smart string allocation strategies
- LLVM Backend - Leverages Rust's optimizing compiler
π‘οΈ Safety & Verification
- Property-Based Testing - QuickCheck for semantic equivalence
- Memory Safety Analysis - Prevents use-after-free and data races
- Bounds Checking - Automatic insertion where needed
- Contract Verification - Pre/post condition checking
π€ AI Integration
- Model Context Protocol - Full MCP v1.0 support
- Interactive Mode - AI-powered transpilation assistance
- Annotation Suggestions - Smart optimization hints
- Complexity Analysis - Migration difficulty assessment
π― Supported Python Features
β Production Ready
- Functions with type annotations
- Basic types (
int
,float
,str
,bool
) - Collections (
List
,Dict
,Tuple
,Set
) - Control flow (
if
,while
,for
,match
) - List and dict comprehensions
- Exception handling β
Result<T, E>
- Basic classes and dataclasses
- Pattern matching (Python 3.10+)
π§ In Development
- Async/await support
- Generator expressions
- Lambda functions
- Class inheritance
- Decorators
β Not Supported
- Dynamic features (
eval
,exec
) - Runtime reflection
- Monkey patching
- Multiple inheritance
π Tool Usage
CLI Interface
# Basic transpilation
# Analysis and verification
# Interactive features
# Quality enforcement
MCP Integration
# Use with Claude or other MCP-compatible AI assistants
# Available MCP tools:
# - transpile_python: Convert Python to Rust
# - analyze_complexity: Code complexity analysis
# - verify_transpilation: Verify semantic equivalence
# - suggest_annotations: Optimization hints
ποΈ Architecture
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Python AST ββββββΆβ HIR ββββββΆβ Rust AST β
β (rustpython) β β (Intermediate) β β (syn) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Type Inference β β Optimizations β β Code Generation β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
π Quality Standards
Following the Toyota Way principles:
θͺεε (Jidoka) - Build Quality In
- Never ship incomplete transpilation
- All generated code must compile
- Verification-first development
ηΎε°ηΎη© (Genchi Genbutsu) - Direct Observation
- Test against real Python codebases
- Profile actual compilation times
- Debug at the Rust level
ζΉε (Kaizen) - Continuous Improvement
- Incremental verification levels
- Performance baselines
- Code quality targets
π§ͺ Testing
# Run all tests
# Run with coverage
# Run property tests
# Run benchmarks
# Run specific test suites
π€ Contributing
We welcome contributions! Please follow our quality standards:
- Write tests first - TDD is mandatory
- Maintain coverage - 85%+ for all new code
- Zero warnings -
cargo clippy -- -D warnings
- Format code -
cargo fmt
- Document changes - Update relevant docs
See CONTRIBUTING.md for detailed guidelines.
π Documentation
- User Guide - Getting started tutorial
- Migration Guide - Python to Rust transition
- API Documentation - Rust API reference
- Python-Rust Spec - Language mapping
- Safety Guarantees - Memory safety analysis
π¦ Roadmap
Current: v1.0 - Core Transpilation β
- Safe subset transpilation
- PMAT quality metrics
- Property-based testing
- Basic MCP integration
Next: v1.1 - Enhanced Type System
- Lifetime inference
- Dataclass support
- Improved string handling
- Contract verification
Future: v1.2 - Advanced Patterns
- Async/await support
- Iterator protocol
- Context managers
- Exception patterns
See ROADMAP.md for detailed plans.
π License
Licensed under the MIT License - see LICENSE for details.
Built with extreme quality standards by the Depyler team