PEP 618: Accepted! (#1435)

And some minor updates.
This commit is contained in:
Brandt Bucher 2020-06-17 15:34:44 -07:00 committed by GitHub
parent 79076e8ddd
commit f95ed1c22e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 10 deletions

View File

@ -5,13 +5,13 @@ Last-Modified: $Date$
Author: Brandt Bucher <brandtbucher@gmail.com>
Sponsor: Antoine Pitrou <antoine@python.org>
BDFL-Delegate: Guido van Rossum <guido@python.org>
Status: Draft
Status: Accepted
Type: Standards Track
Content-Type: text/x-rst
Created: 01-May-2020
Python-Version: 3.10
Post-History: 01-May-2020, 10-May-2020
Resolution:
Post-History: 01-May-2020, 10-May-2020, 16-Jun-2020
Resolution: https://mail.python.org/archives/list/python-dev@python.org/message/NLWB7FVJGMBBMCF4P3ZKUIE53JPDOWJ3
Abstract
@ -119,14 +119,16 @@ occur at the point when iteration would normally stop today.
Backward Compatibility
======================
This change is fully backward-compatible.
This change is fully backward-compatible. ``zip`` currently takes no
keyword arguments, and the "non-strict" default behavior when
``strict`` is omitted remains unchanged.
Reference Implementation
========================
The author has drafted a `C implementation
<https://github.com/python/cpython/compare/master...brandtbucher:zip-strict>`_.
<https://github.com/python/cpython/pull/20921>`_.
An approximate Python translation is::
@ -144,13 +146,16 @@ An approximate Python translation is::
if not strict:
return
if items:
i = len(items) + 1
raise ValueError(f"zip() argument {i} is too short")
i = len(items)
plural = " " if i == 1 else "s 1-"
msg = f"zip() argument {i+1} is shorter than argument{plural}{i}"
raise ValueError(msg)
sentinel = object()
for i, iterator in enumerate(iterators[1:], 2):
for i, iterator in enumerate(iterators[1:], 1):
if next(iterator, sentinel) is not sentinel:
raise ValueError(f"zip() argument {i} is too long")
plural = " " if i == 1 else "s 1-"
msg = f"zip() argument {i+1} is longer than argument{plural}{i}"
raise ValueError(msg)
Rejected Ideas
==============