作者walelile (wakaka)
看板Python
标题[闲聊] Python 3.5.0b2 release
时间Tue Jun 9 06:21:11 2015
Python 3.5.0b2 release
link:
https://docs.python.org/3.5/whatsnew/3.5.html
What's New (compared to 3.4)
Syntax features:
- matrix multiplication operator: a @ b
- coroutines with async and await syntax (PEP492)
New lib modules:
- zipapp
New built-in features:
- bytes % args, bytearray % args
- hex() method has been added to bytes, bytearray
and memoryview
Significatly Imporved Library Modules:
- collections.OrderedDict is now implemented in C (4x~100x)
- tempfile
Implementation Improvements:
(略,看不懂)
Security Improvements:
None yet
--------------------------
PEP 492: Coroutines with async and await syntax
以前判断是否为coroutine的方法为检查function body中
是否有yield from or yield,但这种作法在refactoring
的时候, yield or yield from的消失或出现会造成不明显
的错误。
过去asynchronous calls会因为yield的语法限制,不被
允许出现在with和for中。
- async with, async for
Example:
async def read_data(db):
async with db.transaction():
data = await db.fetch('SELECT ...')
---------------------------
在看async东西时刚好看到doc後面没挂(dev)就放上来分享。
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 1.171.40.10
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1433802076.A.992.html