-
Notifications
You must be signed in to change notification settings - Fork 787
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
Add abi3 + num_bigint conversion #3198
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidhewitt Could you give advices? I left questions.
src/conversions/num_bigint.rs
Outdated
}; | ||
py.get_type::<PyLong>() | ||
.call_method("from_bytes", (bytes_obj, "little"), kwargs) | ||
.expect("TODO") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How should I handle errors in to_object? Is this not expected to be implemented for abi3 or unwrap can be ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now .expect()
is ok , we will eventually improve this in #1813, it's helpful if you could add a // FIXME #1813 or similar
here.
src/conversions/num_bigint.rs
Outdated
@@ -128,6 +166,32 @@ macro_rules! bigint_conversion { | |||
} | |||
} | |||
} | |||
|
|||
#[cfg(Py_LIMITED_API)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where will be the proper places to put the limited api implementation? Like now or a new file or module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the only thing which changes here is the implementation of how to get n_bytes
, so I think we can do something like:
let n_bytes = cfg_if::cfg_if! {
if #[cfg(not(Py_LIMITED_API))] {
// fast path
} else {
// slow path
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Questions replied to, also this will need a file newsfragments/3198.added.md
, I suggest the following contents:
Add support for `num-bigint` feature in combination with `abi3`.
src/conversions/num_bigint.rs
Outdated
@@ -2,7 +2,7 @@ | |||
// | |||
// based on Daniel Grunwald's /~https://github.com/dgrunwald/rust-cpython | |||
|
|||
#![cfg(all(feature = "num-bigint", not(any(Py_LIMITED_API))))] | |||
#![cfg(all(feature = "num-bigint"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#![cfg(all(feature = "num-bigint"))] | |
#![cfg(feature = "num-bigint")] |
src/conversions/num_bigint.rs
Outdated
}; | ||
py.get_type::<PyLong>() | ||
.call_method("from_bytes", (bytes_obj, "little"), kwargs) | ||
.expect("TODO") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now .expect()
is ok , we will eventually improve this in #1813, it's helpful if you could add a // FIXME #1813 or similar
here.
src/conversions/num_bigint.rs
Outdated
@@ -128,6 +166,32 @@ macro_rules! bigint_conversion { | |||
} | |||
} | |||
} | |||
|
|||
#[cfg(Py_LIMITED_API)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the only thing which changes here is the implementation of how to get n_bytes
, so I think we can do something like:
let n_bytes = cfg_if::cfg_if! {
if #[cfg(not(Py_LIMITED_API))] {
// fast path
} else {
// slow path
}
}
First time contributor has agreed to the new licensing scheme. |
@DataTriny Thank you. #3108 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks for implementing this!
bors r+ |
Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
Fix #3196