Async Techniques and Examples in Python Transcripts
Chapter: Parallelism in C with Cython
Lecture: C and Python are friends
0:00 When you talk about Python in performance
0:03 it's really interesting because
0:04 Python code itself is kind of slow compared to languages like
0:09 C#, Java, definitely C++, things like that.
0:13 So, you say well this code is slow.
0:15 But you can actually write a whole bunch more functionality
0:18 with way fewer bugs really quickly.
0:21 And then you can try to make it faster.
0:22 A lot of the stuff we talked about with parallelism
0:24 it lets us do many things faster
0:26 and if you're waiting on other systems, perfect.
0:28 Maybe though, you're working with something computational.
0:31 You might bring in some library like NumPy
0:33 for data science or numerical computations.
0:36 And that really mixes up the performance
0:38 because the internals in NumPy are written in C.
0:42 And it's highly optimized.
0:43 So, maybe you're version written in C
0:45 would actually be slower than Python's version using NumPy.
0:48 I don't know. This is a hypothetical, right?
0:50 Another way to think about this is
0:52 certain parts of your Python code are really critical
0:55 and most of them aren't.
0:57 So, if you think about SQLAlchemy
1:00 there's a little tiny internal bit
1:02 that is written in C that goes really, really fast
1:05 and then the rest of it you'd do in Python.
1:08 But that's not the slow part.
1:09 The slow part is actually not in Python, its in C.
1:12 So, this Python, C integration
1:14 is really interesting and really important.
1:17 Now, you may be thinking, Micheal.
1:19 I either don't know C or C++ or I
1:22 hate working in C and C++ that's why I'm a Python developer.
1:25 Fine, I'm with you. It's been a long time since I been
1:27 a professional C++ developer. A really long time.
1:30 What we're going to talk about here
1:32 is actually how we can take advantage of this
1:35 performance and integration that we get with
1:37 Python's great compatibility with C
1:39 without actually writing any C code at all.
1:42 Sounds perfect doesn't it?