itertools.starmap
provides a solution for the non-concurrent case:
from itertools import starmap
results = list(starmap(twoparameterfunction,
itertools.combinations([1, 2, 3, 4, 5], 2)))
For a multiprocessing map, you can't use starmap. (You also can't use multiple input iterables, so you wouldn't have been able to use the zip-transpose solution either.) In that case, it's probably best to define a helper that takes a tuple and passes the elements to twoparameterfunction
:
def starfunc(x_y):
return twoparameterfunction(*x_y)
results = some_appropriate_pool.map(
starfunc, itertools.combinations([1, 2, 3, 4, 5], 2))