Skip to content

[RFC]  #2369

Closed
Closed

Description

@ismaelxyz

Reading .pyc, .so, .dll y .pyd

Want to use RustPython before the new year

Detailed Explanation

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:

  1. Why doesn't RustPython read the bytecode files it creates?

  2. Why doesn't RustPython read .so, .dll, .pyc, .pyd, .so (equivalent to .pyd of Windows for Linux) files?

  3. Don't you think it's time RustPython reads .so and .dll like Python does with ctypes, well, also .pyd and .so.

Activity

  1. coolreader18 commented on Dec 14, 2020

    @coolreader18
    Member

    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".

  2. ismaelxyz commented on Dec 15, 2020

    @ismaelxyz
    Author

    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.
    Captura de pantalla_área-de-selección_20201215003215
    Captura de pantalla_área-de-selección_20201215003249
    pyexport2
    Captura de pantalla_área-de-selección_20201215003416
    Captura de pantalla_área-de-selección_20201215003457

    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.

  3. coolreader18 commented on Dec 15, 2020

    @coolreader18
    Member

    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.

  4. ismaelxyz commented on Dec 15, 2020

    @ismaelxyz
    Author

    That is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRequest for comments

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions