You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
Well, still posible. It is similar to a mypyc approach.
Rather than generating rust AST, we can pre-compile the python code to native using rustpython-jit at the moment.
Then it will be more approachable, and be able to fallback to python code when it is not compilable well.
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.
I checked Cython code and realized it is not true C, and it does not generate pure C code.
If Cython could generate pure C code, that would be good. Then I could convert .py to .c, compile it fully natively, achieve true C-level speed, and then connect it back to Python. @arihant2math
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 import logging; logging.info('hello'), you can turn it into C ast and compile it, but where the logging library come from? That's python library. And thats what Cython and mypyc do. You'd better check out what crystal lang achieved and limited.
And the goal of RustPython is neither transpiler nor crystal. It is obvious.
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.
Activity
coderabbitai commentedon Dec 19, 2025
📝 CodeRabbit Plan Mode
Generate an implementation plan and prompts that you can use with your favorite coding agent.
Examples
🔗 Similar Issues
Related 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
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord or schedule a call!
fanninpm commentedon Dec 19, 2025
The problem of trans-piling Python code into Rust is likely beyond the scope of this project.
youknowone commentedon Dec 20, 2025
Well, still posible. It is similar to a mypyc approach.
Rather than generating rust AST, we can pre-compile the python code to native using
rustpython-jitat the moment.Then it will be more approachable, and be able to fallback to python code when it is not compilable well.
MominIqbal-1234 commentedon Dec 20, 2025
I found this project: https://github.com/paiml/depyler. It mentions RustPython.
i appreciate all developers and this effort @youknowone
[-]Why not Python to Rust[/-][+]Why not .py to .rs[/+]arihant2math commentedon Jan 5, 2026
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.
MominIqbal-1234 commentedon Jan 6, 2026
I checked Cython code and realized it is not true C, and it does not generate pure C code.
If Cython could generate pure C code, that would be good. Then I could convert .py to .c, compile it fully natively, achieve true C-level speed, and then connect it back to Python. @arihant2math
youknowone commentedon Jan 6, 2026
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
import logging; logging.info('hello'), you can turn it into C ast and compile it, but where the logging library come from? That's python library. And thats what Cython and mypyc do. You'd better check out what crystal lang achieved and limited.And the goal of RustPython is neither transpiler nor crystal. It is obvious.
fanninpm commentedon Jan 12, 2026
What about Nuitka?1
Footnotes
Currently, Nuitka does not work on Arch Linux due to an incompatibility with Python 3.14. ↩
arihant2math commentedon Jan 12, 2026
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.