>>> from multiprocessing import Pool
>>> def f(x, y):
... return x*y
>>> p = Pool(3)
>>> p.map(f, [1,2,3], [4,5,6])
And I look errors TypeError: unorderable types: list() <= int().
How to use Pool with 2 lists?
The problem is with the map function not the Pool object. For this case, starmap would be a good choice like this:
p.starmap(f, zip([1,2,3], [4,5,6]))
From python 3.3 starmap was added to the Pool object
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With