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 noticed that you have a stdlib implementation in rust. Not sure how complete it is. But there are probably more projects that are trying to innovate in the python ecosystem without using C-API and GIL.
Wouldn't it be better if these projects collaborated and produced one stdlib implementation that is usable by multiple projects?
Subsequently this can be transpiled to many languages, each using the language specific FFI. But the core library remains in a restricted subset of python that could be transpiled.
Mojo is likely considering doing this as well (but in mojo, not statically typed python).
Drawbacks, Rationale, and Alternatives
Breaks compatibility. Not sure if pypy will consider it.
Unresolved Questions
Some unresolved questions in the issue tracker of the project linked.
Thank you for suggestion. We not only borrowed python libraries from CPython, but also from other pure python libraries pypy(mostly rewritten in rpython), ouroboros(discontinued) and brython . This library also can be one of the candidate.
I think trying to stick to the cpython stdlib is good if we want things the ctypes. However this might be a good stopgap solution for certain unimplemented functions. The problem I see is most of the unimplemented functions lie in obscure locations, which this wouldn't cover.
I see ctypes/cffi as a way to get to some native functionality. A transpiler can be taught to convert calls to python cffi to rust ffi.
If your goal is to have python stdlib implemented in rust one day, this might be better aligned with that direction. But I couldn't tell if that's a goal.
Yes - this wouldn't help you with library coverage, since it's far less complete than some of the other implementations.
I believe having pure python backup is always a good idea. It has 2 good points.
First, it can be a step-by-step procedure. For example, CPython also uses _pydatetime.py and both-implemented functools. we have both functools.py and functools.rs. CPython replaces more implementation with C, but we only replace reduce.
Second, it is binary size friendly in a few scenario. Unlike Rust implementation, pure python stdlib can be selected on runtime. Many RustPython users are looking for using it as embedded python. Using pure python will drop the performance but also decrease the size of binary - Because it can be provided from environment on demand
Activity
youknowone commentedon Jan 28, 2025
Thank you for suggestion. We not only borrowed python libraries from CPython, but also from other pure python libraries pypy(mostly rewritten in rpython), ouroboros(discontinued) and brython . This library also can be one of the candidate.
adsharma commentedon Jan 28, 2025
Thank you for that pointer. I guessed someone must've tried to do this before. I couldn't discover it via searches:
https://github.com/beeware/ouroboros
A few differences vs other efforts:
arihant2math commentedon Jan 28, 2025
I think trying to stick to the cpython stdlib is good if we want things the ctypes. However this might be a good stopgap solution for certain unimplemented functions. The problem I see is most of the unimplemented functions lie in obscure locations, which this wouldn't cover.
adsharma commentedon Jan 28, 2025
I see ctypes/cffi as a way to get to some native functionality. A transpiler can be taught to convert calls to python cffi to rust ffi.
If your goal is to have python stdlib implemented in rust one day, this might be better aligned with that direction. But I couldn't tell if that's a goal.
Yes - this wouldn't help you with library coverage, since it's far less complete than some of the other implementations.
youknowone commentedon Feb 1, 2025
I believe having pure python backup is always a good idea. It has 2 good points.
First, it can be a step-by-step procedure. For example, CPython also uses
_pydatetime.pyand both-implemented functools. we have bothfunctools.pyandfunctools.rs. CPython replaces more implementation with C, but we only replace reduce.Second, it is binary size friendly in a few scenario. Unlike Rust implementation, pure python stdlib can be selected on runtime. Many RustPython users are looking for using it as embedded python. Using pure python will drop the performance but also decrease the size of binary - Because it can be provided from environment on demand