Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2
In this example the result would be the same with usual synchronous code. Typically, not just in Python, using async is beneficial if the code is "IO bound". This means that the bottleneck is the speed of the input/output operations, which is typically a case for running code across different networks. For example you may have a program with a UI that the user is interacting with. The user may press a button to start fetching the data, from a website or from a database. If this takes a long time, a blocking synchronous code would prevent the user from doing something else, while the task is still running. So using async would definitely have some benefit here.
22nd Dec 2022, 11:49 AM
Tibor Santa
Tibor Santa - avatar