It looks like you are using a module multiprocessing. You did not say, and this is important information.
A function .map()in an instance multiprocessing.Pool()takes two arguments: a function and a sequence. The function will be called with sequential values from the sequence. You are trying to convey a ysequence, and it will not work.
: ((y, x) for x in input) , , , - .
multiprocessing.Pool() , , , : , dict, .
, , . , :
import multiprocessing as mp
def f(x):
return (x, x*x)
if __name__ == '__main__':
pool = mp.Pool()
inputs = range(10)
result = dict(pool.map(f, inputs))
result : {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81}
, x*x x , . . , f() , (key, x, p), x**p.
import multiprocessing as mp
def f(tup):
key, x, p = tup
return (key, x**p)
if __name__ == '__main__':
pool = mp.Pool()
inputs = range(10)
inputs = [("1**1", 1, 1), ("2**2", 2, 2), ("2**3", 2, 3), ("3**3", 3, 3)]
result = dict(pool.map(f, inputs))
, , , zip() , , itertools.product.