22.04.20 11:20, Antoine Pitrou пише:
Ideally, that's what it would do. Whether it's desirable to transition
to that behaviour is an open question.
But, as far as I'm concerned, the number of times where I took
advantage of zip()'s current acceptance of heteregenously-sized inputs
is extremely small. In most of my uses of zip(), a size difference
would have been a logic error that deserves noticing and fixing.
I concur with Antoine. Ideally we should have several functions:
zip_shortest(), zip_equal(), zip_longest(). In most cases (80% or 90% or
more) they are equivalent, because input iterators has the same length,
but it is safer to use zip_equal() to catch bugs. In other cases you
would use zip_shortest() or zip_longest(). And it would be natural to
rename the most popular variant to just zip().
Now it is a breaking change. We had a chance to do it in 3.0, when other
breaking change was performed in zip(). I do not know if it is worth to
do now. But when we plan any changes in zip() we should take into
account possible future changes and make them simpler, not harder.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/WVKVCRYBQGYOYAELXWQH76Q7VJEGDC53/
Code of Conduct: http://python.org/psf/codeofconduct/