V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
janxin
V2EX  ›  Python

Tornado 4.3b1,支持 async/await 关键字

  •  
  •   janxin · 2015-10-19 18:04:00 +08:00 · 2472 次点击
    这是一个创建于 3113 天前的主题,其中的信息可能已经有所发展或是发生改变。

    Highlights

    • The new async/await keywords in Python 3.5 are supported. In most cases, async def can be used in place of the @gen.coroutine decorator. Inside a function defined with async def, use await instead of yield to wait on an asynchronous operation. Coroutines defined with async/await will be faster than those defined with @gen.coroutine and yield, but do not support some features including .Callback/.Wait or the ability to yield a Twisted Deferred.
    • The async/await keywords are also available when compiling with Cython in older versions of Python.

    Deprecation notice

    • This will be the last release of Tornado to support Python 2.6 or 3.2. Note that PyPy3 will continue to be supported even though it implements a mix of Python 3.2 and 3.3 features.

    更多的请看:http://www.tornadoweb.org/en/latest/releases/next.html

    不知道 asyncio 的库是不是可以直接用在 Tornado 上面了,如果可以我就升到 3.5 了....

    10 条回复    2015-10-19 22:53:53 +08:00
    aliuwr
        1
    aliuwr  
       2015-10-19 18:17:52 +08:00
    Python 3.5 感觉好远
    janxin
        2
    janxin  
    OP
       2015-10-19 19:46:38 +08:00
    @aliuwr 之前一直停留在 2.7 ,之前觉得 yield from 这个实在是不优雅,不过有 async/await 要好很多了
    echo1937
        3
    echo1937  
       2015-10-19 19:51:20 +08:00
    还在 3.43,有先行者吗?
    chengzhoukun
        4
    chengzhoukun  
       2015-10-19 19:56:18 +08:00
    JS 也快支持了
    Feiox
        5
    Feiox  
       2015-10-19 20:07:25 +08:00
    @echo1937 我们已经开始实验 3.5 了,因为现在的项目使用了一些 asyncio 。其实对我们更有吸引力的是 typing 这个标准库 ~ 已经准备大刀阔斧的迁移了。
    话说, PHP7 Node 都配备了 JIT , CPython 何时来拯救我们 ~
    echo1937
        6
    echo1937  
       2015-10-19 20:09:53 +08:00
    @Feiox 请问下,你们是什么项目?
    Feiox
        7
    Feiox  
       2015-10-19 20:15:26 +08:00
    @echo1937 一个不太要求速度的爬虫,一些业务逻辑,还有几个内部使用的 Py 库(处理抽象业务逻辑的)。主要还是和 Web 业务、文本数据的处理有关。
    PythonAnswer
        8
    PythonAnswer  
       2015-10-19 20:49:06 +08:00
    感觉 tornado 又要来一波爆发了.
    django 之类的不知道什么时候才能引入 async await
    fy
        9
    fy  
       2015-10-19 22:14:33 +08:00
    3.4 的时候就已经转了 py3 ,感觉良好。

    顺便再厚着脸皮推一下自己的 Tornado 项目模板: https://github.com/fy0/fpage
    janxin
        10
    janxin  
    OP
       2015-10-19 22:53:53 +08:00
    @PythonAnswer django 本来就是同步模型,跟异步关系应该不大,即使引入范围也不会大的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5437 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 09:07 · PVG 17:07 · LAX 02:07 · JFK 05:07
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.