def f(i, n):
    return i * i + 2 * n

def main():
    import multiprocessing
pool = multiprocessing.Pool(2)
ans = pool.map(functools.partial(f, n=20), list(range(100000)))
return ans
Python multiprocessing a function with several inputs