Add more int functions to the c-api#8159
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughExpanded the PyLong C-API with new constructors and extractors, extended integer FfiResult outputs, and changed PyInt unsigned mask handling. ChangesPyLong C-API expansion
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
6aa3a82 to
3d85bb2
Compare
|
@coderabbitai resume |
✅ Action performedReviews resumed. |
3d85bb2 to
2a94827
Compare
| #[must_use] | ||
| pub fn as_u64_mask(&self) -> u64 { | ||
| let v = self.as_bigint(); | ||
| v.to_u64() |
There was a problem hiding this comment.
I didn't investigate the detail yet, but trying to_u64 looks like redundant operation if the fallback still use the last digits
There was a problem hiding this comment.
Agreed. Looking at the simplified logic this feels redundant.
There was a problem hiding this comment.
I've also applied this to the u32 function
acec52f to
b8835a8
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/capi/src/longobject.rs`:
- Around line 92-106: The flag parsing in
AsNativeBytesFlags::from_bits_or_default currently accepts the reserved endian
value 2 because it passes through AsNativeBytesFlags::from_bits; add an explicit
rejection for that raw flag before the generic bitmask check so
PyLong_FromNativeBytes and PyLong_FromUnsignedNativeBytes raise ValueError for 2
while still preserving the existing default behavior for -1. Keep the Default
implementation unchanged, since Self::NATIVE_ENDIAN | Self::UNSIGNED_BUFFER is
correct, and ensure the new validation is localized to from_bits_or_default so
both call sites inherit it automatically.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: e0d68fea-f4dd-4ac0-9ab6-740c9eee9e6b
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (2)
crates/capi/Cargo.tomlcrates/capi/src/longobject.rs
4cf4334 to
ad92c2c
Compare
|
@coderabbitai resume |
✅ Action performedReviews resumed. |
2bffd0c to
18e54a6
Compare
18e54a6 to
4ad78c4
Compare
4ad78c4 to
18f4929
Compare
Summary by CodeRabbit
PyLong_From*constructors for doubles, signed/unsigned 32- and 64-bit values, native-endian byte buffers, C strings (optional end-pointer), andvoid*/pointer-sized values.PyLong_As*conversions (typed signed/unsigned, size types, and mask variants), replacingPyLong_AsLong.