Python 3.9 有什麼新功能¶
- 編輯者:
Łukasz Langa
本文介紹了 Python 3.9 與 3.8 相比多了哪些新功能。Python 3.9 已於 2020 年 10 月 5 日發布。有關完整詳細資訊,請參閱 changelog。
也參考
PEP 596 - Python 3.9 發佈時程
發布重點摘要¶
新增語法特性:
PEP 584, union operators added to
dict;PEP 585, type hinting generics in standard collections;
PEP 614, relaxed grammar restrictions on decorators.
新的內建功能:
PEP 616, string methods to remove prefixes and suffixes.
New features in the standard library:
PEP 593, flexible function and variable annotations;
os.pidfd_open()added that allows process management without races and signals.
直譯器的改進:
PEP 573, fast access to module state from methods of C extension types;
PEP 617, CPython now uses a new parser based on PEG;
a number of Python builtins (range, tuple, set, frozenset, list, dict) are now sped up using PEP 590 vectorcall;
garbage collection does not block on resurrected objects;
a number of Python modules (
_abc,audioop,_bz2,_codecs,_contextvars,_crypt,_functools,_json,_locale,math,operator,resource,time,_weakref) now use multiphase initialization as defined by PEP 489;a number of standard library modules (
audioop,ast,grp,_hashlib,pwd,_posixsubprocess,random,select,struct,termios,zlib) are now using the stable ABI defined by PEP 384.
新的函式庫模組: