I'm trying to run a function like f in parallel in Python but have two problems:
- When using
map, functionfis not applied to all permuted tuples of arraysaandb. - When trying to use
Pool, I get the following error:
TypeError: '<=' not supported between instances of 'tuple' and 'int'
def f(n,m):
x = n * m
return x
a = (1,2,3,4,5)
b = (3,4,7,8,9)
result = map(f, a, b)
print(list(result))
#now trying parallel computing
from multiprocessing import Pool
pool = Pool(processes=4)
print(*pool.map(f, a, b))
mapdocumentation say? Exactly which function calls do you want to be made for this input, and why?