How to Speed Up Python Code with Threading [Tutorial]

preview_player
Показать описание
Multithreading and multiprocessing allow computers to multitask and perform various tasks at the same time.
These concepts also help provide insane speedups to Python code.

In this video I will present the threading module in Python.
But first, I briefly explain threads, processes and the differences between parallelism and concurrency. Due to the global interpreter lock Python multithreading only achieves concurrency and not parallelism.

We look at some examples of how to speed up a Python program by using multiple threads. Finally, I also demonstrate through a code example how multithreading only leads to speed up in IO bound applications (and not CPU bound ones).

Source code:

00:00 intro
00:29 what are threads and processes?
01:12 client and server example
01:36 Global interpreter lock
01:55 parallelism vs. concurrency
03:53 Code: simple multithreading
05:30 Code: speed up with multithreading
07:16 Code: multithreading fails at CPU bound tasks
08:19 End

Please consider liking if you found the video useful and subscribe for more!

Рекомендации по теме
Комментарии
Автор

A must watch for the intermediate python programmer!

hamzamunir
visit shbcf.ru