Skip to content

Conversation

@youknowone
Copy link
Member

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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 28, 2025

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@arihant2math
Copy link
Collaborator

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?

@youknowone
Copy link
Member Author

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
Copy link
Member Author

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.

Copy link
Collaborator

@ShaharNaveh ShaharNaveh left a comment

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants