This doc contains all the changes that are not included in summary doc of Python 3.10, & contains:
- Libraries not directly related to framework
- Updates in Internal libraries
- Miscellaneous changes
Other Language Changes (link)
-
If object.ipow() returns NotImplemented, the operator will correctly fall back to object.pow() and object.rpow() as expected.
-
The views returned by dict.keys(), dict.values() and dict.items() now all have a mapping attribute that gives a types.MappingProxyType object wrapping the original dictionary.
-
Builtin and extension functions that take integer arguments no longer accept Decimals, Fractions and other objects that can be converted to integers only with a loss (e.g. that have the int() method but do not have the index() method).
-
Assignment expressions can now be used unparenthesized within set literals and set comprehensions, as well as in sequence indexes (but not slices). (more details here)
-
Functions have a new
__builtins__
attribute which is used to look for builtin symbols when a function is executed, instead of looking into__globals__['__builtins__']
. The attribute is initialized from__globals__["__builtins__"]
if it exists, else from the current builtins.
[Annotations]
-
Annotations for complex targets (everything beside
simple name
targets defined by PEP 526) no longer cause any runtime effects withfrom __future__ import annotations
. -
Annotations consist of
yield
,yield from
,await
or named expressions are now forbidden underfrom __future__ import annotations
due to their side effects. -
Usage of unbound variables, super() and other expressions that might alter the processing of symbol table as annotations are now rendered effectless under from future import annotations.
[Error Related]
-
A
SyntaxError
(instead of aNameError
) will be raised when deleting the__debug__
constant. -
SyntaxError
exceptions now haveend_lineno
andend_offset
attributes. They will beNone
if not determined.
-
The
LOAD_ATTR
instruction now uses new “per opcode cache” mechanism. It is about 36% faster now for regular attributes and 44% faster for slots. -
When building Python with
--enable-optimizations
now-fno-semantic-interposition
is added to both the compile and link line.- This speeds builds of the Python interpreter created with
--enable-shared
withgcc
by up to 30%. - See this article for more details.
- This speeds builds of the Python interpreter created with
-
Use a new output buffer management code for
bz2
/lzma
/zlib
modules, and add.readall()
function to_compression.DecompressReader
class. bz2 decompression is now 1.09x ~ 1.17x faster, lzma decompression 1.20x ~ 1.32x faster,GzipFile.read(-1)
1.11x ~ 1.18x faster.- In framework,
zlib
is used inserde.py
&ray.py
- In framework,
-
Micro-optimizations to
_PyType_Lookup()
to improve type attribute cache lookup performance in the common case of cache hits. This makes the interpreter 1.04 times faster on average. -
The following built-in functions now support the faster PEP 590 vectorcall calling convention:
map()
,filter()
,reversed()
,bool()
andfloat()
-
BZ2File
performance is improved by removing internalRLock
. This makesBZ2File
thread unsafe in the face of multiple simultaneous readers or writers, just like its equivalent classes ingzip
andlzma
have always been.
zimport.zipimporter.load_module()
has been deprecated in preference forexec_module()
.
[ImportLib]
-
The various implementations of
importlib.abc.MetaPathFinder.find_module()
(importlib.machinery.BuiltinImporter.find_module()
,importlib.machinery.FrozenImporter.find_module()
,importlib.machinery.WindowsRegistryFinder.find_module()
,importlib.machinery.PathFinder.find_module()
,importlib.abc.MetaPathFinder.find_module()
),importlib.abc.PathEntryFinder.find_module()
(importlib.machinery.FileFinder.find_module()
), andimportlib.abc.PathEntryFinder.find_loader()
(importlib.machinery.FileFinder.find_loader()
) now raiseDeprecationWarning
and are slated for removal in Python 3.12 -
The deprecations of imp,
importlib.find_loader()
,importlib.util.set_package_wrapper()
,importlib.util.set_loader_wrapper()
,importlib.util.module_for_loader()
,pkgutil.ImpImporter
, andpkgutil.ImpLoader
have all been updated to list Python 3.12 as the slated version of removal (they began raising DeprecationWarning in previous versions of Python). -
The import system now uses the
__spec__
attribute on modules before falling back onmodule_repr()
for a module’s__repr__()
method.
[SQLite]
-
sqlite3.OptimizedUnicode
has been deprecated, scheduled for removal in Python 3.12. As it has been undocumented and obsolete since Python 3.3 -
sqlite3.enable_shared_cache
is now deprecated, scheduled for removal in Python 3.12.- See the SQLite3 docs for more details.
- If a shared cache must be used, open the database in URI mode using the
cache=shared
query parameter.
[Other]
-
These
ssl
features have been deprecated since Python 3.6, Python 3.7, or OpenSSL 1.1.0 and will be removed in 3.11. -
The threading debug (
PYTHONTHREADDEBUG
environment variable) is deprecated in Python 3.10 and will be removed in Python 3.12.
-
Removed special methods
__int__
,__float__
,__floordiv__
,__mod__
,__divmod__
,__rfloordiv__
,__rmod__
and__rdivmod__
of thecomplex
class. They always raised aTypeError
. -
The
ParserBase.error()
method from the private and undocumented_markupbase
module has been removed.html.parser.HTMLParser
is the only subclass ofParserBase
and itserror()
implementation was already removed in Python 3.5. -
Removed the
unicodedata.ucnhash_CAPI
attribute which was an internal PyCapsule object. The related private_PyUnicode_Name_CAPI
structure was moved to the internal C API. -
Removed the
parser
module, which was deprecated in 3.9 due to the switch to the new PEG parser, as well as all the C source and header files that were only being used by the old parser, includingnode.h
,parser.h
,graminit.h
andgrammar.h
. -
Removed the Public C API functions
PyParser_SimpleParseStringFlags
,PyParser_SimpleParseStringFlagsFilename
,PyParser_SimpleParseFileFlags
andPyNode_Compile
that were deprecated in 3.9 due to the switch to the new PEG parser. -
Removed the
formatter
module, which was deprecated in Python 3.4. It is somewhat obsolete, little used, and not tested. -
Removed the
PyModule_GetWarningsModule()
function that was useless now due to the_warnings
module was converted to a builtin module in 2.6.