rust-lang / rust-lang/rfcs

I hope there could be an official tool used to transfer python code to rust code automatically?

Open
#3,126 28 comments 85 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Markdown
Stars
6.6k
Forks
1.7k
Avg merge
16h 14m
Merged PRs (30d)
1

Description

(I am not pretty sure if the below suggestion could be treated as a RFC, but I think it is useful for rust development.)

We know Rust aims to be a stable and productive programming language. But at present, its ecosystem lacks a lot of wheels. Meanwhile, Python is on the very opposite position. Therefore, I think it would make Rust more productive if Rust could absorb Python's ecosystem(many mature wheels) as soon as possible.

I know there are many people trying to make wheels to enrich Rust ecosystem, some for python users. But there are still some problems for people to transfer Python code to Rust. Let's take the popular Python module numpy as an example:

  1. indeed, there are some crates try to simulate numpy module. BUT, people would not be confident enough to use them as they are not official supported by numpy team.
  2. The time: it would take quite a long time to make them mature enough as they are in Python, even the corresponding Rust crates are supported officially by original python module team?
  3. No ganrantee on support for teams those built many popular Python modules to make corresponding crates in Rust.

So, I am asking if it is possible to build a tool like Rustfmt OFFICIALLY by Rust team, with witch could be used to automatically tranpile any Python script code(including module used in script) into corresponding Rust code, like pyrs does?

With such a tool:

  1. it is possible to program in Python for checking logic first, then transpile it automatically to Rust to make the whole programming routine efficient enough--- this routine, at least I think is the best way to do programming constructively and productively.
  2. people would be confident enough to use it as it is officialy supported.
  3. This saves people a lot of time, instead of spending time on building crates that will be unstable for quite a long time.

Someone would ask why I stick to only Python?

  1. Python is the most popular used language with the best ecosystem, the ecosystem feature is exactly Rust lacks MOST.
  2. For those compiled languge, like C++, there is always a way to use wheels from their field through FFI, let alone some crates to do it , like cxx. But Python is an interpreted language with an official interpreter contains GIL,even with some crates, like pyo3, it still makes Rust program not efficient enough due to GIL.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository file, test, or implementation entry point is identified; begin with the RFC discussion and the cited Rustfmt and pyrs projects. Determine whether an officially supported Python-to-Rust transpiler can be scoped, including imported modules and Python ecosystem/GIL constraints; done would require a concrete, reviewable RFC proposal rather than a broad request.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python, rust
Domain
compilers, devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
18/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.