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
Hi, I have a new year's wish to ask the RustPython Team.
I was thinking of using RustPython as an alternative to CPython for Christmas. But it turns out that RustPython does not offer an alternative to ctypes such as a ffi library that connects to rust (at least).
Drawbacks, Rationale, and Alternatives
If RustPython does not read its own .pyc files, they will only serve to waste space in the memory of its users' PCs, making them more annoying than they already are for those who do not use them (such as students and people who are testing for bugs).
By not reading .so and .dll (Libraries) RustPython is at a disadvantage to other Python implementations that can read Libraries.
By not reading .pyd and .so (Pyhon extensions) RustPython is at a disadvantage to other Python implementations that can read Python extensions.
I love Rust and I love Python with pyo3 (a crate) I can make them work together. With RustPython Rust rules and barely leaves room for almost unnecessary Python co-existence (that's what I think after doing so much code in Rus and Little in Python using RustPython source code).
CPython can coexistence at the same time or at different times with Go (Golang), Rust, C++, C, Ruby and others. With RustPython this coexistence does not exist.
Unresolved Questions
Maybe I'm a little rough but:
Why doesn't RustPython read the bytecode files it creates?
Why doesn't RustPython read .so, .dll, .pyc, .pyd, .so (equivalent to .pyd of Windows for Linux) files?
Don't you think it's time RustPython reads .so and .dll like Python does with ctypes, well, also .pyd and .so.
There is currently work being done on ctypes in #2364. What exactly do you mean by "RustPython does not read its own .pyc files"? As far as I can tell, importlib does check for precompiled pyc files -- if I edit the compiler, I have to remove the __pycache__ directories or else the code won't get recompiled.
As for your questions:
Why doesn't RustPython read .so, .dll, .pyc, .pyd, .so (equivalent to .pyd of Windows for Linux) files?
We don't have a C API yet, so we can't load native modules yet. We've put lots of effort into having a nice API for using rustpython as a dependency, but we would have to completely reimplement the whole API to use from external C libraries. Our current thought is implement the HPy API, which I think @windelbouwman has worked on a bit, but it's not possible to have a solution as easy as "depend on rustpython in Cargo.toml and run cargo build".
Wow, what you're telling me doesn't make me happy. But I'm not sad because I know that one day RustPython will be better than it already is.
My current version of RustPyhon was downloaded a fortnight ago. The only modification I made to it was to change its name to Rupyn (a shorter name) and the images explain what I said.
RustPython creates a pycache folder where it saves the bytecode files which are not readable by the interpreter who created them (RustPython) or by CPython.
Ah, I see what you mean. That shouldn't be too hard to implement, it looks like cpython just checks if the extension is .pyc and loads it as bytecode if it is.
Activity
coolreader18 commentedon Dec 14, 2020
There is currently work being done on ctypes in #2364. What exactly do you mean by "RustPython does not read its own .pyc files"? As far as I can tell, importlib does check for precompiled pyc files -- if I edit the compiler, I have to remove the
__pycache__directories or else the code won't get recompiled.As for your questions:
We don't have a C API yet, so we can't load native modules yet. We've put lots of effort into having a nice API for using rustpython as a dependency, but we would have to completely reimplement the whole API to use from external C libraries. Our current thought is implement the HPy API, which I think @windelbouwman has worked on a bit, but it's not possible to have a solution as easy as "depend on rustpython in Cargo.toml and run
cargo build".ismaelxyz commentedon Dec 15, 2020
Wow, what you're telling me doesn't make me happy. But I'm not sad because I know that one day RustPython will be better than it already is.





My current version of RustPyhon was downloaded a fortnight ago. The only modification I made to it was to change its name to Rupyn (a shorter name) and the images explain what I said.
RustPython creates a pycache folder where it saves the bytecode files which are not readable by the interpreter who created them (RustPython) or by CPython.
coolreader18 commentedon Dec 15, 2020
Ah, I see what you mean. That shouldn't be too hard to implement, it looks like cpython just checks if the extension is
.pycand loads it as bytecode if it is.ismaelxyz commentedon Dec 15, 2020
That is correct.