Skip to content

Latest commit

 

History

History
99 lines (56 loc) · 9.55 KB

new-in-3.10(not included).md

File metadata and controls

99 lines (56 loc) · 9.55 KB

(Not covered) New in Python 3.10

This doc contains all the changes that are not included in summary doc of Python 3.10, & contains:

  1. Libraries not directly related to framework
  2. Updates in Internal libraries
  3. Miscellaneous changes

New Features

  1. PEP 612: Parameter Specification Variables
  2. Optional EncodingWarning and encoding="locale" option

Other Language Changes (link)

  1. If object.ipow() returns NotImplemented, the operator will correctly fall back to object.pow() and object.rpow() as expected.

  2. 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.

  3. 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).

  4. 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)

  5. 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]

  1. Annotations for complex targets (everything beside simple name targets defined by PEP 526) no longer cause any runtime effects with from __future__ import annotations.

  2. Annotations consist of yieldyield fromawait or named expressions are now forbidden under from __future__ import annotations due to their side effects.

  3. 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]

  1. SyntaxError (instead of a NameError) will be raised when deleting the __debug__ constant.

  2. SyntaxError exceptions now have end_lineno and end_offset attributes. They will be None if not determined.


Optimizations

  1. 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.

  2. 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 with gcc by up to 30%.
    • See this article for more details.
  3. 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 in serde.py & ray.py
  4. 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.

  5. The following built-in functions now support the faster PEP 590 vectorcall calling convention: map()filter()reversed()bool() and float()

  6. BZ2File performance is improved by removing internal RLock. This makes BZ2File thread unsafe in the face of multiple simultaneous readers or writers, just like its equivalent classes in gzip and lzma have always been.


Deprecated

  1. zimport.zipimporter.load_module() has been deprecated in preference for exec_module().

[ImportLib]

  1. 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() ), and importlib.abc.PathEntryFinder.find_loader() ( importlib.machinery.FileFinder.find_loader() ) now raise DeprecationWarning and are slated for removal in Python 3.12

  2. The deprecations of imp, importlib.find_loader(), importlib.util.set_package_wrapper(), importlib.util.set_loader_wrapper(), importlib.util.module_for_loader(), pkgutil.ImpImporter, and pkgutil.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).

  3. The import system now uses the __spec__ attribute on modules before falling back on module_repr() for a module’s __repr__() method.

[SQLite]

  1. sqlite3.OptimizedUnicode has been deprecated, scheduled for removal in Python 3.12. As it has been undocumented and obsolete since Python 3.3

  2. 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]

  1. 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.

  2. The threading debug (PYTHONTHREADDEBUG environment variable) is deprecated in Python 3.10 and will be removed in Python 3.12.


Removed

  1. Removed special methods __int____float____floordiv____mod____divmod____rfloordiv____rmod__ and __rdivmod__ of the complex class. They always raised a TypeError.

  2. The ParserBase.error() method from the private and undocumented _markupbase module has been removed. html.parser.HTMLParser is the only subclass of ParserBase and its error() implementation was already removed in Python 3.5.

  3. 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.

  4. 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, including node.hparser.hgraminit.h and grammar.h.

  5. Removed the Public C API functions PyParser_SimpleParseStringFlagsPyParser_SimpleParseStringFlagsFilenamePyParser_SimpleParseFileFlags and PyNode_Compile that were deprecated in 3.9 due to the switch to the new PEG parser.

  6. Removed the formatter module, which was deprecated in Python 3.4. It is somewhat obsolete, little used, and not tested.

  7. Removed the PyModule_GetWarningsModule() function that was useless now due to the _warnings module was converted to a builtin module in 2.6.