Skip to content

5-ary izip #1042

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

Merged
merged 10 commits into from
Mar 21, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion stdlib/2/itertools.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ def izip(iter1: Iterable[_T1], iter2: Iterable[_T2],
@overload
def izip(iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3],
iter4: Iterable[_T4]) -> Iterator[Tuple[_T1, _T2,
_T3, _T4]]: ... # TODO more than four iterables
_T3, _T4]]: ...
@overload
def izip(iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3],
iter4: Iterable[_T4], iter5: Iterable[_T5])
-> Iterator[Tuple[_T1, _T2, _T3, _T4, _T5]]: ... # TODO more than five iterables
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a syntax error - the "->" needs to be on the same line.

Also, would

@overload
def izip(*iter: Iterable) -> Iterator[tuple]: ...

do the trick?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that while that would work for n-ary calls, it would drop type information for the individual tuple positions, so spelling it out may be worth the tradeoff here and work in more cases. The use cases I've seen for izip are often of the form

for foo, bar in itertools.izip(foos, bars):
  frobnicate(foo, bar)

and it would make sense to keep the type information for foo and bar around.


def izip_longest(*p: Iterable[Any],
fillvalue: Any = ...) -> Iterator[Any]: ...

Expand Down