-
Notifications
You must be signed in to change notification settings - Fork 783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constructors for PyLong
and PyInt
#2221
Comments
Thanks for the suggestion! One thing that is tricky is deciding what this function should look like. Should it accept just a single integer type, or should it accept multiple types, via a trait? Fwiw, I have used |
@mejrs if this is not being worked on happy to take it on? |
Please do! |
@iyakushev I have some local changes for a future PR, so yes working on it. Though some discussion on whether it should be:
would be beneficial. I can make a PR and we can move the discussion there, unless @mejrs thinks otherwise? |
as of now, is it possible to build rust functions that return |
Is there a workaround for this? I'm having a hard time to build a PyInt/PyLong object from rust numeric types. |
@nicoCalvo as @mejrs said, you can go the into_py route and then downcast. For interest, what to you need the PyLong object for? |
@birkenfeld Thanks. I solved with rust native |
@nicoCalvo I have to admit I don't understand that code. What is the original type of |
Most types in
pyo3::types
have helper methods to create them easily (examples:PyString::new
,PyBool::new
). Is there a reason why there is no such method forPyLong
andPyInt
or is it an overlook ? Could we imagine adding them ?Being able to build python objects in an easy and type-safe manner is a real strength of
pyo3
, and having a hole here seems a bit weird.The text was updated successfully, but these errors were encountered: