| 1 | initial version |
You can try something like this:
import functools
import multiprocessing
N_CPU = multiprocessing.cpu_count()
print('CPUs:',N_CPU)
def myprod(g1,w,u2):
return max(t*w*u2 for t in g1, key=lambda t: t.length())
with multiprocessing.Pool(processes=N_CPU) as pool:
winner = max( pool.imap_unordered(functools.partial(myprod,g1,w), g2), key=lambda t: t.length() )
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.