New submission from Joachim: 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): time.sleep(1) return x*x if __name__ == '__main__': start_time = time.time() with Pool(4) as p: print(p.map(f, 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. ---------- assignee: docs@python components: Documentation messages: 287895 nosy: docs@python, j5w6 priority: normal severity: normal status: open title: doc 17.2.1: basic Pool example is too basic versions: Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29575> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com