I use something similar to the following to parallelize a for loop over two matrices
from joblib import Parallel, delayed import numpy def processInput(i,j): for k in range(len(i)): i[k] = 1 for t in range(len(b)): j[t] = 0 return i,j a = numpy.eye(3) b = numpy.eye(3) num_cores = 2 (a,b) = Parallel(n_jobs=num_cores)(delayed(processInput)(i,j) for i,j in zip(a,b))
but I get the following error: too many values ββto unpack (2 expected)
Is there a way to return 2 values ββwith a delay? Or what solution do you propose?
In addition, the OP bit, is there a more compact way, for example, the following (which does not actually modify anything) for processing matrices?
from joblib import Parallel, delayed def processInput(i,j): for k in i: k = 1 for t in b: t = 0 return i,j
I would like to avoid using has_shareable_memory anyway to avoid possible bad interactions in the actual script and lower specs (?)
source share