rustpython-cpython by youknowone · Pull Request #6301 · RustPython/RustPython
Test code:
import _cpython @_cpython.call def decimal_add(a, b): import _decimal return _decimal.Decimal(a) + _decimal.Decimal(b) result = decimal_add('1.1', '2.2') # '3.3' print(result)
Test command:
cargo run --features cpython test_cpython.py
This might be something awful. Now RustPython can borrow any feature from CPython, as long as CPython is in the environment and the calling function’s arguments and return type are pickle-serializable.
Will this become a new RustPython feature? Otherwise I’ll just create it outside the org repo.
Important
Review skipped
Draft detected.
Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
✨ Finishing touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
We could just replace the ctypes implementation with this :). Would make life much easier.
This sort of strays away from the mission of having a pure-rust compiler no?
We could just replace the ctypes implementation with this :). Would make life much easier.
On environments with available CPythons, that makes sense. But we are more likely on wasm targets.
This sort of strays away from the mission of having a pure-rust compiler no?
This will be optional feature. Not every data is pickle-serializable. It hopefully will fill gaps until we have rust implementation for them
| print("OK!\n") | ||
|
|
||
|
|
||
| # Test 3: import_module() with numpy |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now RustPython can run numpy.
Though it will not be that much practical.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, very cool!
I do agree that this goes against the project goal in some ways. BUT if we have it behind a feature flag (that's not on by default) then I don't see an issue with letting users choose this functionality.
As an added bonus can we state somewhere in the docs that we have (experimental) support for installing packages that use extension modules (not pure python), like pandas, numpy, pedantic, etc...?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters