pythonCopyfrom joblib import Parallel, delayed
import math
def sqrt_func(i, j):
time.sleep(1)
return math.sqrt(i**j)
Parallel(n_jobs=2)(delayed(sqrt_func)(i, j) for i in range(5) for j in range(2))
foo = [1, 2, 3]
bar = [4, 5, 6]
parallel_sum = []
for f, b in zip(foo, bar):
print(f, b)
parallel_sum.append(f + b)
print(parallel_sum)
# 1 4
# 2 5
# 3 6
# [5, 7, 9]