22. Multiprocessing vs Threading
Both threading and multiprocessing provide concurrency, but with different trade-offs.
Threading
- Lightweight
- Shares memory
- Limited by GIL
Multiprocessing
- Heavyweight
- Separate memory space
- True parallelism
Wrap-Up
Choose threading for I/O-bound tasks, multiprocessing for CPU-bound tasks.