Python Multithreading & Multiprocessing and Why You Should Avoid Them

preview_player
Показать описание
Why You Should Avoid Multithreading & Multiprocessing in Python?
0. Global Interpreter Lock
2. Most things you can think of as multithreaded applications and such might actually be already multithreaded because it is calling some C code.
3. There are realities that are hidden in the implementations that no one teaches you, e.g. pickling to share data etc. And this has 2 major problems: (1) the larger community is unaware of these issues and (2) this becomes a bad cycle as people start to teach these concepts without going in any depths. As learners, too many times we are told that just use the package and it is fast without knowing what is happening.
4. It is extremely hard to debug because of 2.
5. Why not use another language, like Rust, to write your computation intensive part of code?

Obviously, there are still times when multithreading can be helpful, like downloading a lot of stuff. Multiprocessing is, well, a little too much overhead in most cases. When using OOP in Python, you have to be very careful when you want to use multiprocessing in your class methods. It might copy too much data, or your class object just cannot be pickled.

Slip of mouth at 29:00. I mean multithreading...

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

This video was amazing. A brutal exposé on the inefficiencies of Python. Hard to believe this garbage language has become the defacto standard for data science.

ArthurSchoppenweghauer