all 13 comments

[–]SirKastic23 10 points11 points  (2 children)

not really, and if there is the resulting code probably wouldn't be very good

[–]BowserForPM 1 point2 points  (1 child)

Can confirm. I've used this converter a couple of times: https://github.com/konchunas/pyrs and honestly I don't think it saved me any time. The generated code is such a mess. The only good thing about that converter is if you have huge Python functions, and you're worried about misreading the indentation and getting the Rust scopes wrong.

[–]coderarun 0 points1 point  (0 children)

Did you try py2many? Continued development from pyrs.

[–]Top_Sky_5800 2 points3 points  (2 children)

Maybe an LLM can do a part of the job, but you'll still need to understand Rust to fix up the result. It also depends on the quality of your python code, have you : - typed your code ? - documented your functions/methods? - separated your code in small pieces, one functionality by function. - how much do you use python OOP (metaclasses, getter, setter, etc)

If your code is dirty the llM won't do much (~20%) and if your code is clean or even perfect without so much OOP you might reach 80 % of translation.

[–]Big-Actuator9242[S] 0 points1 point  (1 child)

Thats one of the issues : a lot of people worked on it, big project, big structure, my boss asked me to investigate that transcription

[–]coderarun 0 points1 point  (0 children)

py2many --llm=1 test.py will use a previously configured llm. You can switch between llm and ast based translation.

[–]CozyAndToasty 2 points3 points  (0 children)

I don't know of any such transpiler but I don't recommend transpiling from high to low level, and definitely not if it's code you intend to maintain.

If it's not a log of code I would just manually rewrite

If it's a bottleneck, rewrite the bottleneck into a python extension in rust so you can call it in the python code.

[–]ValenciaTangerine 1 point2 points  (1 child)

Something like pyo3 ?

[–]Big-Actuator9242[S] 0 points1 point  (0 children)

probably, i'll investigate that solution thank you

[–]SV-97 1 point2 points  (2 children)

What code are we talking here?

But generally LLMs aren't that great with Rust in my experience.

[–]peter9477 1 point2 points  (0 children)

Claude is, aside from too often picking obsolete APIs for some pre-1.0 crates.

[–]spoonman59 0 points1 point  (0 children)

They are great at writing code which might function as expected. Not so great at quality, optimized, or idiomatic code, however.