Skip to content

Commit 0e80b56

Browse files
authored
bpo-40334: Add What's New sections for PEP 617 and PEP 585 (GH-19704)
1 parent 5aafa54 commit 0e80b56

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

Doc/whatsnew/3.9.rst

+43
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,49 @@ to easily remove an unneeded prefix or a suffix from a string. Corresponding
115115
added. See :pep:`616` for a full description. (Contributed by Dennis Sweeney in
116116
:issue:`18939`.)
117117

118+
PEP 585: Builtin Generic Types
119+
------------------------------
120+
121+
In type annotations you can now use built-in collection types such as
122+
``list`` and ``dict`` as generic types instead of importing the
123+
corresponding capitalized types (e.g. ``List`` or ``Dict``) from
124+
``typing``. Some other types in the standard library are also now generic,
125+
for example ``queue.Queue``.
126+
127+
Example:
128+
129+
.. code-block:: python
130+
131+
def greet_all(names: list[str]) -> None:
132+
for name in names:
133+
print("Hello", name)
134+
135+
See :pep:`585` for more details. (Contributed by Guido van Rossum,
136+
Ethan Smith, and Batuhan Taşkaya in :issue:`39481`.)
137+
138+
PEP 617: New Parser
139+
-------------------
140+
141+
Python 3.9 uses a new parser, based on `PEG
142+
<https://en.wikipedia.org/wiki/Parsing_expression_grammar>`_ instead
143+
of `LL(1) <https://en.wikipedia.org/wiki/LL_parser>`_. The new
144+
parser's performance is roughly comparable to that of the old parser,
145+
but the PEG formalism is more flexible than LL(1) when it comes to
146+
designing new language features. We'll start using this flexibility
147+
in Python 3.10 and later.
148+
149+
The :mod:`ast` module uses the new parser and produces the same AST as
150+
the old parser.
151+
152+
In Python 3.10, the old parser will be deleted and so will all
153+
functionality that depends on it (primarily the :mod:`parser` module,
154+
which has long been deprecated). In Python 3.9 *only*, you can switch
155+
back to the LL(1) parser using a command line switch (``-X
156+
oldparser``) or an environment variable (``PYTHONOLDPARSER=1``).
157+
158+
See :pep:`617` for more details. (Contributed by Guido van Rossum,
159+
Pablo Galindo and Lysandros Nikolau in :issue:`40334`.)
160+
118161

119162
Other Language Changes
120163
======================

0 commit comments

Comments
 (0)