Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are the async/await keywords in python 3.5 inspired by async/await in C#? [closed]

async/await (syntax and keywords) in python 3.5 is very similar to async/await in C#.

C# example:

async void asyncTask(){
    await asyncMethod()
}

Python example:

async def asyncTask():  
    await async_method()

Question: is the async/await in python 3.5 inspired by async/await in C#? If yes, why?

like image 810
hadi Avatar asked Aug 28 '17 11:08

hadi


1 Answers

In PEP 492 (the proposal to add the await and async keywords) it was mentioned that C# uses them (besides others):

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).

(Emphasis mine)

So the keyword names were indeed inspired by C# (and other languages) and as for "why" that's also explained in the last paragraph.

like image 71
MSeifert Avatar answered Oct 03 '22 06:10

MSeifert