possible to define *asynchronous generators*::
async def ticker(delay, to):
- """Yield numbers from 0 to `to` every `delay` seconds."""
+ """Yield numbers from 0 to *to* every *delay* seconds."""
for i in range(to):
yield i
await asyncio.sleep(delay)
07:00:00 UTC = 02:00:00 EST 0
The values of the :attr:`fold <datetime.datetime.fold>` attribute have the
-value `0` all instances except those that represent the second
+value ``0`` for all instances except those that represent the second
(chronologically) moment in time in an ambiguous case.
.. seealso::
before the first use of the affected name in the same scope.
Previously this was a ``SyntaxWarning``.
+* It is now possible to set a :ref:`special method <specialnames>` to
+ ``None`` to indicate that the corresponding operation is not available.
+ For example, if a class sets :meth:`__iter__` to ``None``, the class
+ is not iterable.
+ (Contributed by Andrew Barnert and Ivan Levkivskyi in :issue:`25958`.)
+
* Long sequences of repeated traceback lines are now abbreviated as
``"[Previous line repeated {count} more times]"`` (see
:ref:`whatsnew36-traceback` for an example).
collections
-----------
-The new :class:`~collections.Collection` abstract base class has been
+The new :class:`~collections.abc.Collection` abstract base class has been
added to represent sized iterable container classes.
+(Contributed by Ivan Levkivskyi, docs by Neil Girdhar in :issue:`27598`.)
+
+The new :class:`~collections.abc.Reversible` abstract base class represents
+iterable classes that also provide the :meth:`__reversed__`.
+(Contributed by Ivan Levkivskyi in :issue:`25987`.)
The :func:`~collections.namedtuple` function now accepts an optional
keyword argument *module*, which, when specified, is used for
in Python 3.5, all changes introduced in Python 3.6 have also been
backported to Python 3.5.x.
+The :mod:`typing` module has a much improved support for generic type
+aliases. For example ``Dict[str, Tuple[S, T]]`` is now a valid
+type annotation.
+(Contributed by Guido van Rossum in `Github #195
+<https://github.com/python/typing/pull/195>`_.)
+
The :class:`typing.ContextManager` class has been added for
representing :class:`contextlib.AbstractContextManager`.
(Contributed by Brett Cannon in :issue:`25609`.)
* The :class:`Task <asyncio.tasks.Task>` now has an optimized
C implementation. (Contributed by Yury Selivanov in :issue:`28544`.)
+* Various implementation improvements in the :mod:`typing` module
+ (such as caching of generic types) allow up to 30 times performance
+ improvements and reduced memory footprint.
+
* The ASCII decoder is now up to 60 times as fast for error handlers
``surrogateescape``, ``ignore`` and ``replace`` (Contributed
by Victor Stinner in :issue:`24870`).
* The ASCII and the Latin1 encoders are now up to 3 times as fast for the
- error handler ``surrogateescape`` (Contributed by Victor Stinner in :issue:`25227`).
+ error handler ``surrogateescape``
+ (Contributed by Victor Stinner in :issue:`25227`).
* The UTF-8 encoder is now up to 75 times as fast for error handlers
``ignore``, ``replace``, ``surrogateescape``, ``surrogatepass`` (Contributed