Async Techniques and Examples in Python Transcripts
Chapter: Parallelism in C with Cython
Lecture: Python async landscape: Cython

Login or purchase this course to watch this video and the rest of the course contents.
0:00 It's time to take a different perspective
0:02 on performance and parallelism inside of Python.
0:06 So far, what we've done is we've stayed entirely
0:08 focused on our Python code in the constructs within there
0:13 Asyncio, threading, multiprocessing and so on
0:16 to add parallelism. And, that's a really good place to be.
0:20 I would recommend you spend most of your energy and time there.
0:24 It turns out we can also integrate with extra libraries
0:27 especially in C, and as you probably know C can do anything.
0:32 Our operating systems are generally written in C
0:35 so C is super low-level these days
0:38 and is very very good at performance and parallelism.
0:42 So there might be reasons to think about writing C code
0:46 and integrating that with our program.
0:50 So, here we are and do things faster.
0:52 This has two factors that multiply your performance
0:55 in really interesting ways.
0:56 One, even if we don't do any parallelism
1:00 you'll see that converting certain parts
1:03 of our program to C will make it go way, way faster.
1:08 You'll also see that we can escape the Gil in C
1:11 which means that we can go even faster.
1:13 So we can do basically what we do with multiprocessing
1:16 but in a single process and do that faster as well.
1:19 So there's this double multiplying effect of our performance.
1:22 It's not that I would say jump at first
1:25 but if you have any really performance critical system
1:28 you might think about some of the techniques in this chapter.