python版本 3.7.4rc1 (stable) / 3.8.0b1 (pre-release) / 3.9.0a0 (in development)

Python 3.7.4rc1

Python 3.7 was released on June 27, 2018.

总结–发布精彩

新的语法特性:

  • PEP 563, postponed evaluation of type annotations. 推迟类型注释的计算

向后兼容语法更改:

  • async and await are now reserved keywords. async和wait现在都是保留关键字

新的模块:

  • contextvars: PEP 567 – Context Variables 上下文变量
  • dataclasses: PEP 557 – Data Classes 数据类别
  • importlib.resources

新的内置特性:

  • PEP 553, the new breakpoint() function. 新的breakpoint() 函数

Python 数据模型改进:

  • PEP 562, customization of access to module attributes. 定制对模块属性的访问
  • PEP 560, core support for typing module and generic types. 核心支持类型模块和泛型类型
  • the insertion-order preservation nature of dict objects has been declared to be an official part of the Python language spec. dict对象的插入顺序保存性质已被声明为Python语言规范的官方部分。

CPython 执行改进:

  • 避免使用ASCII作为默认文本编码
  • PEP 552, deterministic .pycs
  • the new development runtime mode 新的开发运行时模式
  • PEP 565, improved DeprecationWarning handling 改进的 DeprecationWarning (弃用警告)处理

C API 改进:

  • PEP 539, new C API for thread-local storage 用于线程本地存储的新C API

文档改进:

  • PEP 545, Python documentation translations 文档翻译
  • New documentation translations: Japanese, French, and Korean.

Python 3.8

注意:
预发布版的用户应该知道,该文档目前处于草稿形式。随着Python 3.8向发行版迈进,它将进行大量的更新,因此即使在阅读了早期版本之后,也值得回顾一下。
一些值得注意的项目还没有涵盖在这里:
* PEP 578 - Runtime audit hooks for potentially sensitive operations        运行时审计挂钩用于潜在的敏感操作
* python -m asyncio runs a natively async REPL        python -m asyncio运行本机异步REPL
* ……

总结–发布精彩

新的语法特性:
Assignment expressions 赋值表达式

  • There is new syntax (the “walrus operator”, :=) to assign values to variables as part of an expression. Example:
if (n := len(a)) > 10:
    print(f"List is too long ({n} elements, expected <= 10)")

Positional-only parameters 仅限位置参数

扫描二维码关注公众号,回复: 6568165 查看本文章
  • There is new syntax (/) to indicate that some function parameters must be specified positionally (i.e., cannot be used as keyword arguments). 有新的语法(/)表示必须在位置指定某些函数参数(不能用作关键字参数)
def pow(x, y, z=None, /):
    r = x**y
    if z is not None:
        r %= z
    return r

Now pow(2, 10) and pow(2, 10, 17) are valid calls, but pow(x=2, y=10) and pow(2, 10, z=17) are invalid.

猜你喜欢

转载自www.cnblogs.com/daemonFlY/p/11069292.html