This is an archive of the discontinued LLVM Phabricator instance.

[ADT] Add `zip_equal` for iteratees of equal lengths
ClosedPublic

Authored by kuhar on Nov 28 2022, 2:04 PM.

Details

Summary

Add a new version of zip that assumes that all iteratees have equal
lengths. The difference compared to zip_first is that zip_equal
checks this assumption in builds with assertions enabled.

This will allow us to clearly express the intent when working with
equally-sized ranges without having to write this assertion manually.

This is similar to Python's zip(..., equal=True) [1] or
more_itertools.zip_equal [2].

I saw this first suggested by @benvanik.

[1] https://peps.python.org/pep-0618/
[2] https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.zip_equal

Diff Detail

Event Timeline

kuhar created this revision.Nov 28 2022, 2:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 28 2022, 2:04 PM
Herald added a subscriber: hanchung. · View Herald Transcript
kuhar requested review of this revision.Nov 28 2022, 2:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 28 2022, 2:04 PM
dblaikie accepted this revision.Nov 28 2022, 4:00 PM

Sounds good :)

This revision is now accepted and ready to land.Nov 28 2022, 4:00 PM
kuhar added a reviewer: kazu.Nov 28 2022, 7:49 PM
This revision was landed with ongoing or failed builds.Nov 29 2022, 4:58 PM
This revision was automatically updated to reflect the committed changes.