Chapter 13. Multiprocessing – When a Single CPU Core Is Not Enough
In the previous chapter, we discussed factors that influence performance and some methods to increase performance. This chapter can actually be seen as an extension to the list of performance tips. In this chapter, we will discuss the multiprocessing module, a module that makes it very easy to make your code run on multiple CPU cores and even on multiple machines. This is an easy way to work around the Global Interpreter Lock (GIL) that was discussed in the previous chapter.
To summarize, this chapter will cover:
- Local multiprocessing
- Remote multiprocessing
- Data sharing and synchronization between processes
Multithreading versus multiprocessing
Within this book we haven't really covered multithreading yet, but you have probably seen multithreaded code in the past. The big difference between multithreading and multiprocessing is that with multithreading everything is still executed within a single process...