Correct integer widths in Rust/Python hand-off #7849
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Various locations in the Rust API take a
usize
as input. For the mostpart, Python integers will successfully be passed in at the correct size
if they fit. Numpy
np.uint64
types, however, will fail conversion ifrunning on a 32-bit machine. This is particularly relevant when the
values are being passed as an array.
Details and comments
Needs to test the wheel builds first - it's fine if it fails macos_arm because there's a separate fix in progress for that.
There are other places where we do an "arbitrary int" ->
usize
hand-off, but I think that PyO3 does the right thing, even if given an effectiveu64
to convert tou32
, provided the represented value fits. I think this method is the only problematic one, because it won't convert arrays ofu64
tou32
(very reasonably).