Write into two lists parallel (Python)

Viewed 29

I try to parallelize the bottom for-loop in Python since for each iteration in the for-loop the current iteration is independent of all others. I found the package "joblib" but couldn't find a solution for how to fill two lists at the same time.

I would highly appreciate your help!

import numpy as np
np.random.seed(42)
matrix = np.random.randn(10,10)
list1 = []
list2 = []

for i in range(10):
    row = matrix[i,:]
    list1.append(np.min(row))
    list2.append(np.max(row))
0 Answers
Related