python3.5中的async/await关键字是否受到C中async/await的启发?

2024-10-05 14:25:09 发布

您现在位置:Python中文网/ 问答频道 /正文

python3.5中的async/await(语法和关键字)与C中的async/await非常相似。在

C#示例:

async void asyncTask(){
    await asyncMethod()
}

Python示例:

^{pr2}$

问题:python3.5中的async/await是否受到C中async/await的启发?如果是,为什么?在


Tags: 示例async语法关键字awaitvoidasynctaskpr2
1条回答
网友
1楼 · 发布于 2024-10-05 14:25:09

PEP 492(建议添加await和{}关键字)中,mentioned是C使用它们的(除其他外):

Why "async" and "await" keywords

async/await is not a new concept in programming languages:

  • C# has it since long time ago [5];
  • proposal to add async/await in ECMAScript 7 [2]; see also Traceur project [9];
  • Facebook's Hack/HHVM [6];
  • Google's Dart language [7];
  • Scala [8];
  • proposal to add async/await to C++ [10];
  • and many other less popular languages.

This is a huge benefit, as some users already have experience with async/await, and because it makes working with many languages in one project easier (Python with ECMAScript 7 for instance).

(重点是我的)

所以关键字名称确实是受到C(和其他语言)的启发,至于“为什么”也在最后一段中解释了。在

相关问题 更多 >