.. PEP-sized items next.
* :pep:`810`: :ref:`Explicit lazy imports for faster startup times
- <whatsnew315-pep810>`
+ <whatsnew315-lazy-imports>`
* :pep:`814`: :ref:`Add frozendict built-in type
<whatsnew315-frozendict>`
* :pep:`799`: :ref:`A dedicated profiling package for organizing Python
profiling tools <whatsnew315-profiling-package>`
* :pep:`799`: :ref:`Tachyon: High frequency statistical sampling profiler
<whatsnew315-sampling-profiler>`
-* :pep:`798`: :ref:`Unpacking in Comprehensions
+* :pep:`798`: :ref:`Unpacking in comprehensions
<whatsnew315-unpacking-in-comprehensions>`
* :pep:`686`: :ref:`Python now uses UTF-8 as the default encoding
<whatsnew315-utf8-default>`
+* :pep:`728`: ``TypedDict`` with typed extra items
+* :pep:`747`: :ref:`Annotating type forms with TypeForm
+ <whatsnew315-typeform>`
* :pep:`782`: :ref:`A new PyBytesWriter C API to create a Python bytes object
- <whatsnew315-pep782>`
+ <whatsnew315-pybyteswriter>`
* :ref:`The JIT compiler has been significantly upgraded <whatsnew315-jit>`
* :ref:`Improved error messages <whatsnew315-improved-error-messages>`
New features
============
-.. _whatsnew315-pep810:
+.. _whatsnew315-lazy-imports:
:pep:`810`: Explicit lazy imports
---------------------------------
.. code-block:: python
lazy import json
- lazy from datetime import datetime
+ lazy from pathlib import Path
- print("Starting up...") # json and datetime not loaded yet
+ print("Starting up...") # json and pathlib not loaded yet
- data = json.loads('{"key": "value"}') # json gets loads here
- now = datetime() # datetime loads here
+ data = json.loads('{"key": "value"}') # json loads here
+ p = Path(".") # pathlib loads here
This mechanism is particularly useful for applications that import many
modules at the top level but may only use a subset of them in any given run.
----------------------------------------
A new :term:`immutable` type, :class:`frozendict`, is added to the :mod:`builtins` module.
-It does not allow modification after creation. A ``frozendict`` is not a subclass of ``dict``;
-it inherits directly from ``object``. A ``frozendict`` is :term:`hashable`
-as long as all of its keys and values are hashable. A ``frozendict`` preserves
+It does not allow modification after creation. A :class:`!frozendict` is not a subclass of ``dict``;
+it inherits directly from ``object``. A :class:`!frozendict` is :term:`hashable`
+as long as all of its keys and values are hashable. A :class:`!frozendict` preserves
insertion order, but comparison does not take order into account.
For example::
.. _whatsnew315-jit:
Upgraded JIT compiler
-=====================
+---------------------
Results from the `pyperformance <https://github.com/python/pyperformance>`__
benchmark suite report
typing
------
+.. _whatsnew315-typeform:
+
* :pep:`747`: Add :data:`~typing.TypeForm`, a new special form for annotating
values that are themselves type expressions.
``TypeForm[T]`` means "a type form object describing ``T`` (or a type
and :c:data:`Py_mod_abi`.
(Contributed by Petr Viktorin in :gh:`137210`.)
-.. _whatsnew315-pep782:
+.. _whatsnew315-pybyteswriter:
* Implement :pep:`782`, the :ref:`PyBytesWriter API <pybyteswriter>`.
Add functions: