
19.06.20 02:57, Guido van Rossum пише:
On Thu, Jun 18, 2020 at 2:36 PM Eric Fahlgren <ericfahlgren@gmail.com <mailto:ericfahlgren@gmail.com>> wrote:
We've implemented the new zip in our sitecustomize.py, and think the keyword makes it easier. I've instructed our development staff to examine all use of zip as they come across them and add either "strict=True" or "strict=False" when they've determined which is appropriate. Any zip calls without an explicit "strict=" will be deemed "unknown" and requiring further investigation.
That's actually a really nice validation of the choice to use a keyword -- none of the other options debated (which were all variations on "give the alternate behavior a different name") would offer the opportunity to state "I've thought about it and it's definitely okay that the iterables have different lengths at this call site." Sure, in most places this would just look redundant, but in large corporate code bases that's exactly the kind of thing that people like to do.
I did not participate in the recent debates, but in the initial discussion it was proposed to add zip_equal() and zip_shortest() as an alias of zip() (with possibility of changing the behavior of zip() in distant future). There are several advantages of a different name over a boolean keyword argument. 1. It is easier to search in the code. 2. It is easier to replace. 3. It looks more distinguishable. 4. It is faster to call function with positional arguments that with keyword arguments (at the level of bytecode and at the level of parsing arguments). 5. And the implementation is simpler. Of course the ship is already sailed, but I was surprised that the keyword variant won, while it was not popular initially.