depyler  by paiml

Python to Rust transpiler for efficient, safe code migration

Created 5 months ago
269 stars

Top 95.6% on SourcePulse

GitHubView on GitHub
Project Summary

Summary Depyler addresses the challenge of migrating Python code to Rust for enhanced performance, memory safety, and energy efficiency. It targets engineers and researchers seeking to transition Python applications, offering semantic preservation, compile-time safety guarantees, and the ability to generate standalone native binaries.

How It Works The project utilizes a multi-stage pipeline: Python AST parsing (via RustPython), High-Level Intermediate Representation (HIR), conservative type inference, and Rust code generation. Key differentiators include semantic verification through property-based testing to ensure behavioral equivalence and memory safety analysis that infers Rust's ownership and borrowing patterns, aiming for correct and safe Rust code by construction.

Quick Start & Requirements Installation is via cargo install depyler. Prerequisites include Rust 1.83.0+ and Python 3.8+ (for testing). The depyler compile script.py command generates a standalone native binary, supporting cross-platform builds and debug/release profiles. Links to CHANGELOG.md and validation reports are provided.

Highlighted Details

  • Single-Shot Compilation: Version 3.20.0 introduced depyler compile for one-step Python-to-native binary creation across platforms.
  • Extensive Stdlib Support: 100% validation of 27 Python standard library modules (151/151 tests passing) makes these components production-ready.
  • Custom Rust Attributes: Python decorators (@rust.attr()) allow injecting Rust attributes (e.g., #[inline], #[derive(...)]) into generated code.
  • ArgumentParser Transpilation: Python argparse is transpiled to Rust clap derive macros.

Maintenance & Community The README does not specify community channels or contributors. A roadmap is available at docs/execution/roadmap.yaml.

Licensing & Compatibility Licensed under the MIT License, which is permissive for commercial use and closed-source linking.

Limitations & Caveats Unsupported features include dynamic Python constructs like eval() and exec(), runtime reflection, multiple inheritance, and monkey patching.

Health Check
Last Commit

1 day ago

Responsiveness

Inactive

Pull Requests (30d)
38
Issues (30d)
119
Star History
43 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.