推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
watsy0007
V2EX  ›  Python

Python 3.8 即将发布了.

  •  
  •   watsy0007 ·
    watsy0007 · Oct 8, 2019 · 10240 views
    This topic created in 2588 days ago, the information mentioned may be changed or developed.

    准备升级了....

    python 3.8 release date

    3.8.0 candidate 2: Monday, 2019-10-07 (if necessary)
    3.8.0 final: Monday, 2019-10-14 (assuming a single release candidate)

    Features for 3.8 Some of the notable features of Python 3.8 include:

    • PEP 570, Positional-only arguments
    • PEP 572, Assignment Expressions
    • PEP 574, Pickle protocol 5 with out-of-band data
    • PEP 578, Runtime audit hooks
    • PEP 587, Python Initialization Configuration
    • PEP 590, Vectorcall: a fast calling protocol for CPython
    • Typing-related: PEP 591 (Final qualifier), PEP 586 (Literal types), and PEP 589 (TypedDict)
    • Parallel filesystem cache for compiled bytecode
    • Debug builds share ABI as release builds
    • f-strings support a handy = specifier for debugging
    • continue is now legal in finally: blocks
    • on Windows, the default asyncio event loop is now ProactorEventLoop
    • on macOS, the spawn start method is now used by default in multiprocessing
    • multiprocessing can now use shared memory segments to avoid pickling costs between processes
    • typed_ast is merged back to CPython
    • LOAD_GLOBAL is now 40% faster
    • pickle now uses Protocol 4 by default, improving performance
    • There are many other interesting changes, please consult the "What's New" page in the documentation for a full list.
    58 replies  •  2019-10-12 00:08:38 +08:00
    alfredsun
    alfredsun
    Oct 8, 2019❤️13
    1
    即将不能用于完成时
    liuzhaowei55
    liuzhaowei55
    Oct 8, 2019
    2
    哎。。。
    watsy0007
    watsy0007
    OP
    Oct 8, 2019
    3
    @alfredsun 准备升级...
    onmyoji
    onmyoji
    Oct 8, 2019
    4
    官网不是还是 3.7.4 吗?
    imkuang
    imkuang
    Oct 8, 2019 via Android
    5
    要那么新干嘛,还在用 3.6🐶
    Juszoe
    Juszoe
    Oct 8, 2019
    6
    哪位总结一下有什么好用的特性
    chenstack
    chenstack
    Oct 8, 2019
    7
    上次看到的 final 日期还是 10.28
    youthfire
    youthfire
    Oct 8, 2019 via iPhone
    8
    3.6 升级到 3.7 的时候感觉性能提升明显,平时用的脚步速度提升了约 15%。这次看看了。
    qlhai
    qlhai
    Oct 8, 2019❤️3
    9
    还在用 2.7 的默默路过
    QingXuJiaZhi
    QingXuJiaZhi
    Oct 8, 2019❤️2
    10
    @alfredsun 中文“了”字结尾不一定是完成时(中文语法本身没有时态)。

    “好了吗?快点出来”
    “快好了,快好了”
    XIVN1987
    XIVN1987
    Oct 8, 2019 via Android
    11
    只有赋值表达式是重大改动吧,,
    deorth
    deorth
    Oct 8, 2019
    12
    子解释器上了吗
    watsy0007
    watsy0007
    OP
    Oct 8, 2019
    13
    @youthfire 是的... 特性的话, [pep 572]( https://www.zhihu.com/question/274823057) 让 python 之父很恼火...
    watsy0007
    watsy0007
    OP
    Oct 8, 2019
    14
    @deorth multiple interpreters ? 这里提案在 [pep 554]( https://www.python.org/dev/peps/pep-0554/) 我看了下 3.9 版本才会发
    mywaiting
    mywaiting
    Oct 8, 2019
    15
    感觉 typing hints 再努力努力,python 就可以考虑分支为动态脚本、静态编译两个实现了

    有哪个大牛去提个 PEP ?
    watsy0007
    watsy0007
    OP
    Oct 8, 2019
    16
    @cmdOptionKana 标注时间了呀. 下周一可以试试了.
    watsy0007
    watsy0007
    OP
    Oct 8, 2019
    17
    @qlhai 升吧.
    watsy0007
    watsy0007
    OP
    Oct 8, 2019
    18
    @mywaiting 不大可能. 可以用 mypy.
    iPhoneXI
    iPhoneXI
    Oct 8, 2019 via Android
    19
    @mywaiting 不太乐观,TypeScript 类型更强,但是也没静态编译到原生二进制吧
    ipwx
    ipwx
    Oct 8, 2019
    20
    我的看法:3.8 也就更新了这两件值得注意的事情

    1、加强了 Type Hinting,增加了 Duck Type Hinting 的支持。
    2、assignment operation。

    小打小闹而已。
    watsy0007
    watsy0007
    OP
    Oct 8, 2019
    21
    @ipwx 嗯, 日常更新. 另外 assignment operation 我还在考虑用不用...
    mywaiting
    mywaiting
    Oct 8, 2019
    22
    @iPhoneXI 我觉得这就是哪天哪个大牛心血来潮搞一下的事情.......
    laike9m
    laike9m
    Oct 8, 2019
    23
    @deorth 没上
    cat9life
    cat9life
    Oct 8, 2019
    24
    @youthfire 会有这种性能提升?
    laike9m
    laike9m
    Oct 8, 2019
    25
    @watsy0007 能用还是尽量用,确实让代码更简洁,毕竟连 C++ 都有类似语法了
    Mohanson
    Mohanson
    Oct 8, 2019 via Android
    26
    @iPhoneXI minits 项目正在做 ts 的静态编译器
    watsy0007
    watsy0007
    OP
    Oct 8, 2019
    27
    @laike9m 是啊...考虑中.
    laike9m
    laike9m
    Oct 8, 2019
    28
    @ipwx Duck Type Hinting 是指?
    youthfire
    youthfire
    Oct 8, 2019
    29
    @cat9life 主要看 changelog 里有没有 performance 提升,当然也和脚本具体内容有关,可能正好是作用到那段代码了,因为平时我都带计时,所以很明显。
    love
    love
    Oct 8, 2019
    30
    python 这越来越复杂,传个参都整这么多花样有必要么,JS 这么简单写起来还比 py 舒服
    watsy0007
    watsy0007
    OP
    Oct 8, 2019
    31
    @love 场景不一样. 不能简单这样比较. 各有各的优劣.
    rogwan
    rogwan
    Oct 8, 2019 via Android
    32
    @watsy0007 我也觉得 pep572 有点画蛇添足。社区那么多人反对,主要理由也是增加的便捷性不大,带来的复杂度提升过冗。
    laike9m
    laike9m
    Oct 8, 2019
    33
    @rogwan 那 Golang 和 C++ 也都在画蛇添足了
    这一期我们稍微聊过一下 572,主要的槽点我认为在于语法没有强制限定使用范围: https://www.pythonhunter.org/episodes/5
    XIVN1987
    XIVN1987
    Oct 8, 2019
    34
    @love
    可是你们还得学 TypeScript 啊,,JS 的很多库(比如 Vue )都用 TypeScript 写了,,
    love
    love
    Oct 8, 2019
    35
    @XIVN1987 我写 js 也全是用 typescript 啊,觉得不难,js 本质是个简单的语言。哪怕在底层 py 的复杂性都完暴 js,元类什么的我以前研究完就觉得过度设计。
    rogwan
    rogwan
    Oct 8, 2019 via Android
    36
    @laike9m 对这点龟叔大概的意思是:有这个方法,你可以不用啊。然后,社区就反对,这不 Pythonic。

    简单说,就是好处坏处都不大,不太符合奥卡姆原理。
    Trim21
    Trim21
    Oct 8, 2019 via Android
    37
    前几天看完了 what's new,感觉不像 3.6 和 3.7 有非常吸引人升级的特性…
    w1573007
    w1573007
    Oct 8, 2019 via Android
    38
    @cmdOptionKana 疑车无据
    ipwx
    ipwx
    Oct 8, 2019 via Android
    39
    XIVN1987
    XIVN1987
    Oct 8, 2019❤️2
    40
    @love
    元类是给库、框架开发人员用的,我们不需要深究

    正是因为 Python 有这些复杂的语法机制,Python 的用户 API 才能这么易用,,

    如果 Python 没有__xxx__那一堆魔法函数,numpy 就不会出现,,没有 numpy 的话 Python 就不可能在数值计算、数据分析、机器学习、深度学习这些领域流行起来

    Python 里的 ORM 也依赖元类实现,,不知道 JS 中的 ORM 相比于 Python 中的 ORM 使用起来怎么样,,没有对比过,,
    mamahaha
    mamahaha
    Oct 8, 2019❤️1
    41
    ## Java
    > 百度为您找到相关结果约 69,100,000 个
    ## python
    > 百度为您找到相关结果约 38,500,000 个
    ## c++
    > 百度为您找到相关结果约 59,700,000 个
    ## golang
    > 百度为您找到相关结果约 24,600,000 个
    XIVN1987
    XIVN1987
    Oct 8, 2019
    42
    PEP 572 还是能够接受的,,毕竟使用场景比较明确,,

    PEP 505 -- None-aware operators 就不能接受了,,还好 Deferred 了,希望不要通过
    XIVN1987
    XIVN1987
    Oct 8, 2019
    43
    @mamahaha

    最好再统计下 github、StackOverflow、google、quora、知乎等多种数据来源综合下,,单一数据说服力不够,,
    laike9m
    laike9m
    Oct 8, 2019 via Android
    44
    @ipwx thanks,这个不错
    lrxiao
    lrxiao
    Oct 8, 2019
    45
    LOAD_GLOBAL is now 40% faster
    这不算巨大提升吗...调用函数都要 LOAD GLOBAL 的
    BOYPT
    BOYPT
    Oct 8, 2019
    46
    (学不动了
    watsy0007
    watsy0007
    OP
    Oct 8, 2019
    47
    @lrxiao 赞
    alfredsun
    alfredsun
    Oct 8, 2019
    48
    @cmdOptionKana 中文没有时态不代表了不能表完成啊
    就举的例子里,“好”和“好了”的区别就是一个是原型一个是表完成啊,你把“好了”封装成名词做句子成分当然就看不出来了。
    sangsi
    sangsi
    Oct 8, 2019
    49
    @BOYPT 同感!
    woshi88
    woshi88
    Oct 9, 2019
    50
    弃坑了,始于 2.7 止于 3.6
    prenwang
    prenwang
    Oct 9, 2019
    51
    multiprocessing can now use shared memory segments to avoid pickling costs between processes 这个好
    venster
    venster
    Oct 9, 2019
    52
    @alfredsun “即将发布”是一个确定的状态,已经发生了,用“了”没毛病。
    watsy0007
    watsy0007
    OP
    Oct 9, 2019
    53
    wuwukai007
    wuwukai007
    Oct 9, 2019
    54
    一定要用 3.6+,提升太明显了!
    watsy0007
    watsy0007
    OP
    Oct 11, 2019
    55
    @wuwukai007 https://docs.python.org/3.8/whatsnew/3.8.html#optimizations 看了下优化部分, 还是挺明显的.

    Improved performance of operator.itemgetter() by *33%*. Optimized argument handling and added a fast path for the common case of a single non-negative integer index into a tuple (which is the typical use case in the standard library).


    Sped-up field lookups in `collections.namedtuple()`. They are now more than two times faster, making them the fastest form of instance variable lookup in Python.


    The list constructor does not overallocate the internal item buffer if the input iterable has a known length (the input implements __len__). This makes the created list *12%* smaller on average.


    Reduced an overhead of converting arguments passed to many builtin functions and methods. This sped up calling some simple builtin functions and methods up to *20–50%*.


    LOAD_GLOBAL instruction now uses new “per opcode cache” mechanism. It is about *40%* faster now.
    lrxiao
    lrxiao
    Oct 11, 2019
    57
    @watsy0007 为什么这个测试结果有这么多不一致的地方...
    watsy0007
    watsy0007
    OP
    Oct 12, 2019
    58
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1489 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 128ms · UTC 06:11 · PVG 14:11 · LAX 22:11 · JFK 01:11
    ♥ Do have faith in what you're doing.