Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6bf87d3

Browse files
committed
Issue #28635: what's new in 3.6: add a few more notes on typing
Per suggestions by Ivan Levkivskyi. Patch by Elvis Pranskevichus.
1 parent 39d2dfe commit 6bf87d3

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

Doc/whatsnew/3.6.rst

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ function body. In Python 3.6 this restriction has been lifted, making it
295295
possible to define *asynchronous generators*::
296296

297297
async def ticker(delay, to):
298-
"""Yield numbers from 0 to `to` every `delay` seconds."""
298+
"""Yield numbers from 0 to *to* every *delay* seconds."""
299299
for i in range(to):
300300
yield i
301301
await asyncio.sleep(delay)
@@ -490,7 +490,7 @@ between two moments in time for which local times are the same::
490490
07:00:00 UTC = 02:00:00 EST 0
491491

492492
The values of the :attr:`fold <datetime.datetime.fold>` attribute have the
493-
value `0` all instances except those that represent the second
493+
value ``0`` for all instances except those that represent the second
494494
(chronologically) moment in time in an ambiguous case.
495495

496496
.. seealso::
@@ -741,6 +741,12 @@ Some smaller changes made to the core Python language are:
741741
before the first use of the affected name in the same scope.
742742
Previously this was a ``SyntaxWarning``.
743743

744+
* It is now possible to set a :ref:`special method <specialnames>` to
745+
``None`` to indicate that the corresponding operation is not available.
746+
For example, if a class sets :meth:`__iter__` to ``None``, the class
747+
is not iterable.
748+
(Contributed by Andrew Barnert and Ivan Levkivskyi in :issue:`25958`.)
749+
744750
* Long sequences of repeated traceback lines are now abbreviated as
745751
``"[Previous line repeated {count} more times]"`` (see
746752
:ref:`whatsnew36-traceback` for an example).
@@ -898,8 +904,13 @@ and :const:`cmath.nanj` to match the format used by complex repr.
898904
collections
899905
-----------
900906

901-
The new :class:`~collections.Collection` abstract base class has been
907+
The new :class:`~collections.abc.Collection` abstract base class has been
902908
added to represent sized iterable container classes.
909+
(Contributed by Ivan Levkivskyi, docs by Neil Girdhar in :issue:`27598`.)
910+
911+
The new :class:`~collections.abc.Reversible` abstract base class represents
912+
iterable classes that also provide the :meth:`__reversed__`.
913+
(Contributed by Ivan Levkivskyi in :issue:`25987`.)
903914

904915
The :func:`~collections.namedtuple` function now accepts an optional
905916
keyword argument *module*, which, when specified, is used for
@@ -1509,6 +1520,12 @@ Since the :mod:`typing` module was :term:`provisional <provisional api>`
15091520
in Python 3.5, all changes introduced in Python 3.6 have also been
15101521
backported to Python 3.5.x.
15111522

1523+
The :mod:`typing` module has a much improved support for generic type
1524+
aliases. For example ``Dict[str, Tuple[S, T]]`` is now a valid
1525+
type annotation.
1526+
(Contributed by Guido van Rossum in `Github #195
1527+
<https://github.com/python/typing/pull/195>`_.)
1528+
15121529
The :class:`typing.ContextManager` class has been added for
15131530
representing :class:`contextlib.AbstractContextManager`.
15141531
(Contributed by Brett Cannon in :issue:`25609`.)
@@ -1692,12 +1709,17 @@ Optimizations
16921709
* The :class:`Task <asyncio.tasks.Task>` now has an optimized
16931710
C implementation. (Contributed by Yury Selivanov in :issue:`28544`.)
16941711

1712+
* Various implementation improvements in the :mod:`typing` module
1713+
(such as caching of generic types) allow up to 30 times performance
1714+
improvements and reduced memory footprint.
1715+
16951716
* The ASCII decoder is now up to 60 times as fast for error handlers
16961717
``surrogateescape``, ``ignore`` and ``replace`` (Contributed
16971718
by Victor Stinner in :issue:`24870`).
16981719

16991720
* The ASCII and the Latin1 encoders are now up to 3 times as fast for the
1700-
error handler ``surrogateescape`` (Contributed by Victor Stinner in :issue:`25227`).
1721+
error handler ``surrogateescape``
1722+
(Contributed by Victor Stinner in :issue:`25227`).
17011723

17021724
* The UTF-8 encoder is now up to 75 times as fast for error handlers
17031725
``ignore``, ``replace``, ``surrogateescape``, ``surrogatepass`` (Contributed

0 commit comments

Comments
 (0)