Multiprocessing vs Threading Python [Duplicate]
I Am Trying to Understand the Advantages of Multiprocessing over Threading. I Know That Multiprocessing Gets Around the Global Interpreter Lock, but What Other...
I am trying to understand the advantages of multiprocessing over threading. I know that multiprocessing gets around the Global Interpreter Lock, but what other advantages are there, and can threading not do the same thing?
12 Answers
Here are some pros/cons I came up with.
Multiprocessing
Must Read
Pros
- Separate memory space
- Code is usually straightforward
- Takes advantage of multiple CPUs & cores
- Avoids GIL limitations for cPython
- Eliminates most needs for synchronization primitives unless if you use shared memory (instead, it's more of a communication model for IPC)
- Child processes are interruptible/killable
- Python
multiprocessingmodule includes useful abstractions with an interface much likethreading.Thread - A must with cPython for CPU-bound processing