-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
[ER] Iterator::zip_exact #85342
Comments
Interesting idea. It would have the benefit of being easier to optimize than the current implementation, background: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Improving.20TrustedRandomAccess.20and.20its.20Zip.20specialization And some cases where one zips with an infinite stream could be made compatible by adding I would propose calling it |
I think |
With regular |
Even if both are |
There are two kinds of checks. One is for safety and the other is just to give the user feedback whether their use of The advantage of Thinking about it, we probably don't even need The safety checks on the other hand can be eliminated via specialization. The default implementation would still use Most importantly, this would allow elimination of all the rust/library/core/src/iter/adapters/zip.rs Lines 288 to 308 in 9964284
rust/library/core/src/iter/adapters/zip.rs Lines 234 to 243 in 9964284
|
A conversation from itertools about what the semantics of its There are a bunch of different ways this could go. For example, let (a_len, b_len) = (a.len(), b.len());
assert!(a_len == b_len);
return (0..a_len).map(|_| (a.next().unwrap(), b.next().unwrap())) |
I don't quite see the advantage of That way we stay as compatible as possible with the current Most optimizations require specialization anyway and we can also use "best effort" as cover for additional checks implemented via specialization.
That would require |
@rustbot label A-iterators C-feature-request T-libs |
Perhaps it's worth having an
Iterator::zip_strict
as in Python 3.10 in the stdlib:https://www.python.org/dev/peps/pep-0618/
The text was updated successfully, but these errors were encountered: