the primary advantage of pools is that they abstract away the overhead of figuring out what code is executing in the main process and which code is running in the subprocess as with the threading api that multiprocessing mimicsit can often be hard to remember who is executing what the pool abstraction restricts the number of places that code in different processes interact with each othermaking it much easier to keep track of pools also seamlessly hide the process of passing data between processes using pool looks much like function callyou pass data into functionit is executed in another process or processesand when the work is donea value is returned it is important to understand that under the hooda lot of work is being done to support thisobjects in one process are being pickled and passed into pipe another process retrieves data from the pipe and unpickles it work is done in the subprocess and result is produced the result is pickled and passed into pipe eventuallythe original process unpickles it and returns it all this pickling and passing data into pipes takes time and memory thereforeit is ideal to keep the amount and size of data passed into and returned from the pool to minimumand it is only advantageous to use the pool if lot of processing has to be done on the data in question armed with this knowledgethe code to make all this machinery work is surprisingly simple let' look at the problem of calculating all the prime factors of list of random numbers this is common and expensive part of variety of cryptography algorithms (not to mention attacks on those algorithms!it requires years of processing power to crack the extremely large numbers used to secure your bank accounts the following implementationwhile readableis not at all efficientbut that' ok because we want to see it using lots of cpu timeimport random from multiprocessing pool import pool def prime_factor(value)factors [for divisor in range( value- )quotientremainder divmod(valuedivisorif not remainderfactors extend(prime_factor(divisor)factors extend(prime_factor(quotient)break