Editor: | TBD |
---|
This article explains the new features in Python 3.14, compared to 3.13.
For full details, see the :ref:`changelog <changelog>`.
Note
Prerelease users should be aware that this document is currently in draft form. It will be updated substantially as Python 3.14 moves towards release, so it's worth checking back even after reading earlier versions.
- None yet.
Added :func:`ast.compare` for comparing two ASTs. (Contributed by Batuhan Taskaya and Jeremy Hylton in :issue:`15987`.)
Added :func:`fnmatch.filterfalse` for excluding names matching a pattern.
(Contributed by Bénédikt Tran in :gh:`74598`.)
- Added the :data:`os.environ.refresh() <os.environ>` method to update :data:`os.environ` with changes to the environment made by :func:`os.putenv`, by :func:`os.unsetenv`, or made outside Python in the same process. (Contributed by Victor Stinner in :gh:`120057`.)
- Add :meth:`pathlib.Path.copy`, which copies the content of one file to another, like :func:`shutil.copyfile`. (Contributed by Barney Gale in :gh:`73991`.)
- Add :meth:`pathlib.Path.copytree`, which copies one directory tree to another. (Contributed by Barney Gale in :gh:`73991`.)
Expose the following :class:`symtable.Symbol` methods:
- :meth:`~symtable.Symbol.is_free_class`
- :meth:`~symtable.Symbol.is_comp_iter`
- :meth:`~symtable.Symbol.is_comp_cell`
(Contributed by Bénédikt Tran in :gh:`120029`.)
- :mod:`asyncio` now uses double linked list implementation for native tasks which speeds up execution by 10% on standard pyperformance benchmarks and reduces memory usage. (Contributed by Kumar Aditya in :gh:`107803`.)
- Passing a complex number as the real or imag argument in the :func:`complex` constructor is now deprecated; it should only be passed as a single positional argument. (Contributed by Serhiy Storchaka in :gh:`109218`.)
- Remove the type, choices, and metavar parameters of :class:`!argparse.BooleanOptionalAction`. They were deprecated since 3.12.
Remove the following classes. They were all deprecated since Python 3.8, and have emitted deprecation warnings since Python 3.12:
- :class:`!ast.Num`
- :class:`!ast.Str`
- :class:`!ast.Bytes`
- :class:`!ast.NameConstant`
- :class:`!ast.Ellipsis`
Use :class:`ast.Constant` instead. As a consequence of these removals, user-defined
visit_Num
,visit_Str
,visit_Bytes
,visit_NameConstant
andvisit_Ellipsis
methods on custom :class:`ast.NodeVisitor` subclasses will no longer be called when theNodeVisitor
subclass is visiting an AST. Define avisit_Constant
method instead.Also, remove the following deprecated properties on :class:`ast.Constant`, which were present for compatibility with the now-removed AST classes:
Use :attr:`!ast.Constant.value` instead.
(Contributed by Alex Waygood in :gh:`119562`.)
Remove the following classes and functions. They were all deprecated and emitted deprecation warnings since Python 3.12:
- :class:`!asyncio.AbstractChildWatcher`
- :class:`!asyncio.SafeChildWatcher`
- :class:`!asyncio.MultiLoopChildWatcher`
- :class:`!asyncio.FastChildWatcher`
- :class:`!asyncio.ThreadedChildWatcher`
- :class:`!asyncio.PidfdChildWatcher`
- :meth:`!asyncio.AbstractEventLoopPolicy.get_child_watcher`
- :meth:`!asyncio.AbstractEventLoopPolicy.set_child_watcher`
- :func:`!asyncio.get_child_watcher`
- :func:`!asyncio.set_child_watcher`
(Contributed by Kumar Aditya in :gh:`120804`.)
- Remove :class:`!collections.abc.ByteString`. It had previously raised a :exc:`DeprecationWarning` since Python 3.12.
- Remove the isdst parameter from :func:`email.utils.localtime`. (Contributed by Hugo van Kemenade in :gh:`118798`.)
Remove deprecated :mod:`importlib.abc` classes:
- :class:`!importlib.abc.ResourceReader`
- :class:`!importlib.abc.Traversable`
- :class:`!importlib.abc.TraversableResources`
Use :mod:`importlib.resources.abc` classes instead:
(Contributed by Jason R. Coombs and Hugo van Kemenade in :gh:`93963`.)
- Remove :mod:`itertools` support for copy, deepcopy, and pickle operations. These had previously raised a :exc:`DeprecationWarning` since Python 3.12. (Contributed by Raymond Hettinger in :gh:`101588`.)
- Remove support for passing additional keyword arguments to :class:`pathlib.Path`. In previous versions, any such arguments are ignored.
- Remove support for passing additional positional arguments to :meth:`pathlib.PurePath.relative_to` and :meth:`~pathlib.PurePath.is_relative_to`. In previous versions, any such arguments are joined onto other.
- Remove deprecated :func:`!pty.master_open` and :func:`!pty.slave_open`. They had previously raised a :exc:`DeprecationWarning` since Python 3.12. Use :func:`pty.openpty` instead. (Contributed by Nikita Sobolev in :gh:`118824`.)
- Remove :data:`!version` and :data:`!version_info` from :mod:`sqlite3`. (Contributed by Hugo van Kemenade in :gh:`118924`.)
- Disallow using a sequence of parameters with named placeholders. This had previously raised a :exc:`DeprecationWarning` since Python 3.12; it will now raise a :exc:`sqlite3.ProgrammingError`. (Contributed by Erlend E. Aasland in :gh:`118928` and :gh:`101693`.)
- Remove :class:`!typing.ByteString`. It had previously raised a :exc:`DeprecationWarning` since Python 3.12.
- Remove deprecated :class:`!Quoter` class from :mod:`urllib.parse`. It had previously raised a :exc:`DeprecationWarning` since Python 3.11. (Contributed by Nikita Sobolev in :gh:`118827`.)
- Using :data:`NotImplemented` in a boolean context will now raise a :exc:`TypeError`. It had previously raised a :exc:`DeprecationWarning` since Python 3.9. (Contributed by Jelle Zijlstra in :gh:`118767`.)
- The :func:`int` built-in no longer delegates to :meth:`~object.__trunc__`. Classes that want to support conversion to integer must implement either :meth:`~object.__int__` or :meth:`~object.__index__`. (Contributed by Mark Dickinson in :gh:`119743`.)
This section lists previously described changes and other bugfixes that may require changes to your code.
Add :c:func:`PyLong_GetSign` function to get the sign of :class:`int` objects. (Contributed by Sergey B Kirpichev in :gh:`116560`.)
Add a new :c:type:`PyUnicodeWriter` API to create a Python :class:`str` object:
- :c:func:`PyUnicodeWriter_Create`.
- :c:func:`PyUnicodeWriter_Discard`.
- :c:func:`PyUnicodeWriter_Finish`.
- :c:func:`PyUnicodeWriter_WriteChar`.
- :c:func:`PyUnicodeWriter_WriteUTF8`.
- :c:func:`PyUnicodeWriter_WriteUCS4`.
- :c:func:`PyUnicodeWriter_WriteWideChar`.
- :c:func:`PyUnicodeWriter_WriteStr`.
- :c:func:`PyUnicodeWriter_WriteRepr`.
- :c:func:`PyUnicodeWriter_WriteSubstring`.
- :c:func:`PyUnicodeWriter_Format`.
- :c:func:`PyUnicodeWriter_DecodeUTF8Stateful`.
(Contributed by Victor Stinner in :gh:`119182`.)
- In the limited C API 3.14 and newer, :c:func:`Py_TYPE` is now implemented as an opaque function call to hide implementation details. (Contributed by Victor Stinner in :gh:`120600`.)
- Macros :c:macro:`!Py_IS_NAN`, :c:macro:`!Py_IS_INFINITY` and :c:macro:`!Py_IS_FINITE` are :term:`soft deprecated`, use instead :c:macro:`!isnan`, :c:macro:`!isinf` and :c:macro:`!isfinite` available from :file:`math.h` since C99. (Contributed by Sergey B Kirpichev in :gh:`119613`.)
- Creating :c:data:`immutable types <Py_TPFLAGS_IMMUTABLETYPE>` with mutable bases was deprecated since 3.12 and now raises a :exc:`TypeError`.