Parallelization with the multiprocessing module
Before jumping onto the discussion of the multiprocessing
module, let's first understand what we mean by parallelization. This will be a very short introduction to parallelization, just enough to understand how to use some features of the multiprocessing
module.
Introduction to parallelization
Imagine you are standing in a long queue at a checkout counter in a grocery store, waiting for your turn. Now, three more counters are opened to serve the customers and the existing queue is split. As a result, you can pay and get out of the store quickly.
Parallelization, in some sense, accomplishes similar results. In this example, each counter can be imagined as a separate process, carrying out independent tasks of accepting payments. The initial queue of the customers can be imagined as your program. This long queue is then divided into independent queues (or tasks), processing them parallely on separate counters (processes).
The Gold Hunt program we...