Skip to content

Add a zip helper that stops at the shortest input #877

Description

@apstndb

it.ZipBy2 currently pads missing values with zero values when inputs have different lengths.

In some cases, a helper that stops as soon as either input is exhausted is safer and more useful. This matches the common “zip shortest” behavior used in many other languages and iterator libraries.

Proposal

Add a new helper in lo/it with “shortest input wins” semantics, for example:

  • ZipShortestBy2
  • ZipShortBy2
  • ZipBy2Shortest

Expected behavior

The helper should yield values only while both input sequences still have elements, and stop when either side ends.

This would help avoid subtle bugs caused by zero-value padding when input lengths differ.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking changeIntroduces changes that break backward compatibility or alter the public API.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions