4 ms·
Threading is nice until you learn about the global interpreter lock. Then you go multiprocessing for everything.
by sleepysysadmin 6y ago
Threading is nice until you learn about the global interpreter lock. Then you go multiprocessing for everything.
- dvfjsdhgfv 6y agoOK, let's get things more straight: * Threads are useful not just for speeding up, but also for parallel execution (storege/network io, graphics, ...) * If you really care about speed and would like to parallelize CPU-bound code, you'll probably do better using another language like C/C++ (or Java, Go, D etc.) for this particular task * In general, threads are used instead of processes because of the overhead involved in creating the latter * Python multiprocessing module isn't the most efficient anyway, for example when passing large objects between processes because of the way they're serialized * It also has some other quirks so I would definitely not advise to use it for "everything".