Author jwuttke
Recipients docs@python, jwuttke
Date 2017-02-15.22:59:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The »basic example of data parallelism using Pool« is too basic. It demonstrates the syntax, but otherwise makes no sense, and therefore is potentially confusing. It is blatant nonsense to run 5 processes when there are only 3 data to be treated. Let me suggest the following:

from multiprocessing import Pool
import time

def f(x):
    return x*x

if __name__ == '__main__':
    start_time = time.time()
    with Pool(4) as p:
        print(, range(20)))
    print("elapsed wall time: ", time.time()-start_time)

The sleep command makes f representative for a function that takes significant time to execute. Printing the elapsed time shows the user that the 20 calls of f have indeed taken place in parallel.
Date User Action Args
2017-02-15 22:59:20jwuttkesetrecipients: + jwuttke, docs@python
2017-02-15 22:59:20jwuttkesetmessageid: <>
2017-02-15 22:59:20jwuttkelinkissue29575 messages
2017-02-15 22:59:20jwuttkecreate