以下代碼將for循環並行化。 import networkx as nx;
import numpy as np;
from joblib import Parallel, delayed;
import multiprocessing;
def core_func(repeat_index, G, numpy_arrary_2D):
for u in G.nodes():
我有加載數據,並通過次循環例如一個功能 def calculate_profit(account):
account_data = load(account) #very expensive operation
for day in account_data.days:
print(account_data.get(day).profit)
因爲數據的加載是昂貴
有關如何在多處理進程池或joblib中實現/調用具有多種參數的函數的任何想法,其中兩個或三個參數隨每次迭代而變化,其餘保持不變。 下面是循環(我需要並行運行):請注意這裏只有idx,string和secondaryf纔會變化。 sep = ['These limits may help reduce', 'though not completely eliminate', 'alcohol rel