Python for the .NET developer Transcripts
Chapter: async and await in Python
Lecture: async and await introduction

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Time to move on to asynchronous programming
0:02 one of my favorite topics, actually.
0:05 We'll see that asynchronous programming in Python
0:08 has a lot of similarities back to C#.
0:11 Do you love the async and await keyword?
0:14 Well, guess what?
0:15 You can have exactly the same thing in Python.
0:18 Literally, it's the same syntax.
0:21 We're going to talk about all the ways that Python
0:23 asynchronous programming is amazing
0:25 and a few of the drawbacks, as well as some libraries
0:28 that alleviate many of those drawbacks.
0:30 So asynchronous programming in Python is really great.
0:33 I would say it is one of the areas where C# and .NET
0:37 actually clearly have Python beat.
0:39 There's a couple reasons for that
0:41 but nonetheless, it's still really good over here.
0:44 In a lot of situations, they're pretty much the same.
0:46 Fill in all those details as we go through.
0:50 When we think about performance
0:51 and writing asynchronous code, we usually do that
0:54 for one of two reasons.
0:56 First, we might be looking for greater scalability.
0:59 Maybe we're writing a web application
1:01 and the web app is talking to the database
1:03 and some external APIs, and things like that.
1:06 So most of the time, it's waiting on other external things
1:09 but if we do this all on just one thread
1:11 or try to just line it all up
1:13 the website won't be able to do other processing
1:15 while it's doing that.
1:17 Threading, threading requests, do help with that
1:19 but we can actually do even better with async and await.
1:22 That's one side of the story, really common
1:25 the other is we want to go faster.
1:27 We want to compute things faster.
1:30 And with modern hardware and modern CPUs
1:32 with multi-core systems, that's truly possible.
1:35 Some of the time we'll see what
1:37 requirements and limitations around Python there are
1:40 but that's certainly one of the reasons you would want
1:42 to add more concurrency to your system
1:44 to take advantage of the hardware you have
1:46 the multi-core system that you already have.