# computes the sqrt of a very many integers in parallel import multiprocessing as mp import numpy as np from time import time as T def main(): res = [] arg = np.arange(1000000) for nproc in range(1,13): if nproc==1: tic = T() root = np.sqrt(arg) toc = T()-tic else: tic = T() with mp.Pool(nproc) as pool: root = pool.map(np.sqrt,arg) toc = T()-tic print(nproc,toc) if __name__ == '__main__': main()