Here is a snippet from my python script where I am performing:a dictionary lookupa cartesian multiplication of a list of len=500 against a list of len=60,calculating a cumulative addition for each multiplcation combinationrepeat this down a 20,000 rowsThis is slowing things way down and making it hard to debug with the ~10 min wait times.  How can I write this in a more efficient way, and that makes use of more than just one CPU?ccle_head, dot_prod_total = [], []with open(ccle_mRNA_file, mode='r') as ccle:    for _ in range(2): #skip to data        next(ccle)    exp_mat = [line.rstrip().split('\t') for line in ccle]for row in exp_mat:    if row[0] != 'Name' and row[1] in pat_mRNA: # data row        n_row = [float(s) for s in row[2:]]        # get ready for some slow matrix multiplication:        prod = [p*n for n in n_row for p in pat_mRNA[row[1]]] # slows here        if dot_prod_total:            dot_prod_total = [cum_prod + prod for (cum_prod,prod)                        in zip(dot_prod_total,prod)] # cumulative addition        else: dot_prod_total = prod  # first record of matrix products     else: ccle_exp_head = row   # header rowHere are the docs for the input params::param ccle_mRNA_file: text file, rows are gene expression across sample columns:param pat_head: list, patient id [pat_1(str), pat_2...]:param pat_mRNA: dict, patient RNA {gene(str):[pat_1(float), pat_2..}:param cell_interest: set, cells of same tissue {cell_1, cell_2}
Matrix Multiplication Python -- Memory Hungry
python;performance;matrix