-
Notifications
You must be signed in to change notification settings - Fork 1k
Improve comments and change PrimitiveArray::from_trusted_len_iter
to take an ExactSizeIterator
#8564
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
base: main
Are you sure you want to change the base?
Conversation
🤖 |
PrimitiveArray::from_trusted_len_iter
to take an ExactSizeIterator
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 @tobixdev -- I also kicked off some benchmarks
where | ||
P: std::borrow::Borrow<Option<<T as ArrowPrimitiveType>::Native>>, | ||
I: IntoIterator<Item = P>, | ||
I: ExactSizeIterator<Item = P>, |
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.
what is the rationale for this change? I am thinking that maybe someone who had an iterator that knew its length but did not implement ExactSizeIterator
would have to change their code
Maybe that is ok, but the implementation doesn't even seem to use any of the methods on ExactSizeIterator
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.
Yeah we just mentioned that as a side note in the last PR. I think it has two advantages:
- Users have at least some help from the type system to avoid safety issues.
- It's consistent with BooleanArray
However, I am also happy with the old 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.
I also think that some of the functions could make use of len instead of size_hint. If we choose to keep ExactSizeIterator
I'll go through them.
I think another cause of incompatibility is caused by users needing to call .into_iter() manually.
🤖: Benchmark completed Details
|
Which issue does this PR close?
This is a follow-up to #8543 . There we discussed two outstanding issues that this PR tries to address.
Rationale for this change
Address the points from the PR.
What changes are included in this PR?
Vec
-specific optimizations)ExactSizeIterator
for thePrimitiveArray
Are these changes tested?
Existing test for
PrimitiveArray
Are there any user-facing changes?
Yes,
PrimitiveArray::from_trusted_len_iter
is more restrictive.