Why not .py to .rs #6710
Replies: 9 comments 2 replies
-
📝 CodeRabbit Plan ModeGenerate an implementation plan and prompts that you can use with your favorite coding agent.
🔗 Similar IssuesRelated Issues 👤 Suggested Assignees🧪 Issue enrichment is currently in open beta.You can configure auto-planning by selecting labels in the issue_enrichment configuration. To disable automatic issue enrichment, add the following to your issue_enrichment:
auto_enrich:
enabled: false💬 Have feedback or questions? Drop into our discord or schedule a call! |
Beta Was this translation helpful? Give feedback.
-
|
The problem of trans-piling Python code into Rust is likely beyond the scope of this project. |
Beta Was this translation helpful? Give feedback.
-
|
Well, still posible. It is similar to a mypyc approach. |
Beta Was this translation helpful? Give feedback.
-
|
I found this project: https://github.com/paiml/depyler. It mentions RustPython.
|
Beta Was this translation helpful? Give feedback.
-
|
Couldn't you use cython to generate a C file and then use a combination of pyo3 and c2rust to convert it? At that point it's simpler to just compile the C file though, as you gain no safety or anything from using the rust version. |
Beta Was this translation helpful? Give feedback.
-
|
I checked Cython code and realized it is not true C, and it does not generate pure C code. |
Beta Was this translation helpful? Give feedback.
-
|
I really don't want to start this kind of discussion here, so it is not a real question. What is true C code? If you have a code And the goal of RustPython is neither transpiler nor crystal. It is obvious. |
Beta Was this translation helpful? Give feedback.
-
Footnotes
|
Beta Was this translation helpful? Give feedback.
-
|
I'd suggest looking into why python cannot be compiled into C/Rust code. Python has fundamental differences that require it to have a runtime interpreter, meaning it can never actually become C code. |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Hi RustPython team — thanks for your great work.
I have a question/idea: RustPython runs Python on a Rust-based interpreter. Have you ever considered supporting the reverse workflow — transpiling Python into Rust code, then compiling it with rustc?
Proposed workflow:
Input: Python source code
Step 1: Parse Python → build AST (RustPython already has a parser/AST)
Step 2: Convert Python AST → Rust AST / Rust source code
Step 3: Compile generated Rust with rustc to produce a native binary
Beta Was this translation helpful? Give feedback.
All reactions