New in Python 3.8.0

Python 3.8.0

发布时间: Oct. 14, 2019

这是一个Python3.8.0的稳定发行版。
Python3.8.0是最新的Python编程语言发行版,ta包含了许多新的特征和优化。

This is the stable release of Python 3.8.0
Python 3.8.0 is the newest major release of the Python programming language, and it contains many new features and optimizations.

与3.7版本对照,3.8的主要新特征:

Major new features of the 3.8 series, compared to 3.7

PEP 572 赋值表达式

PEP 572 , Assignment expressions

使用符号:=,称之赋值表达式也可以称之命名表达式或称之海象运算符,效果是 NAME := expr即用一个表达式的结果给变量赋值。

PEP 570 仅根据位置的参数

PEP 570, Positional-only arguments

在函数定义的时候使用符号/可以强迫使用者在使用函数的时候只能是位置参数而不能是关键字参数。

PEP 587 Python 初始化设置(改善嵌入)

PEP 587, Python Initialization Configuration (improved embedding)

这个PEP主要解决在Python预配置之前可以使用哪些API和功能以及在核心运行时配置之前可以使用哪些API和功能,如果未显式运行预配置,则将使用与Python 3.6行为相匹配的默认设置隐式运行预配置。
我预计会开一个专门的随笔来研究这个PEP(咕咕咕警告)。

PEP 590 Vectorcall:一个CPython 快速调用协议

PEP 590, Vectorcall: a fast calling protocol for CPython

PEP 578 运行时审计钩子

PEP 578, Runtime audit hooks

PEP 574 Pickle协议 5 带OOB数据

PEP 574, Pickle protocol 5 with out-of-band data

与输入有关:PEP 591(最终限定符),PEP 586(文字类型),PEP 589(固定键集字典)

Typing-related: PEP 591 (Final qualifier), PEP 586 (Literal types), and PEP 589 (TypedDict)

用于编译字节码的并行文件系统缓存

Parallel filesystem cache for compiled bytecode

Debug版本和Release版本共享ABI

Debug builds share ABI as release builds

f-strings支持=进行调试

f-strings support a handy = specifier for debugging

continue现在在 finally: 块中是合法的

continue is now legal in finally: blocks

在Windows上,默认的asyncio事件循环现在是ProactorEventLoop

on Windows, the default asyncio event loop is now ProactorEventLoop

在macOS上,现在在multiprocessing中默认情况下使用spawn start方法

on macOS, the spawn start method is now used by default in multiprocessing

现在,multiprocessing可以使用共享内存段来避免进程之间的pickling costs

multiprocessing can now use shared memory segments to avoid pickling costs between processes

typed_ast合并回CPython

typed_ast is merged back to CPython

LOAD_GLOBAL现在快了40%

LOAD_GLOBAL is now 40% faster

pickle现在默认使用Protocol 4协议4,改善了性能

pickle now uses Protocol 4 by default, improving performance

附录

引用资料来源于python官方文档

原文地址:https://www.cnblogs.com/passguan/p/11683258.html