看板 Python 關於我們 聯絡資訊
Hi 大家好, 小弟最近因為要及時 取得第三方資料做非同步, 第三方資料格式是 json format, 因為 json 資料每層物件又包含多個 arry, 故目前是寫三個巢狀的 for 迴圈針對每層做處理取值, for i in jsonLayer1: for i in jsonLayer2: for i in jsonLayer3: 目前是使用 concurrent.futures.ThreadPoolExecutor 中的 executor.map 放置在上述 3 個迴圈, 目前困惑的點效能似乎沒有得到優化, google survey 的結果都是只有執行一個 executor.map, 未看到 executor.map 中的 function 裡面再包一個 executor.map, 在感謝版上的大大若有相關資訊提供分享~ 若有更好的非同步套件也謝謝分享~~~~~~~ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.163.209.96 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1556688955.A.13A.html
lemon651: parse json這種計算密集在python用thread是完全沒用的 05/01 14:51
lemon651: 你要找的是multiprocessing 05/01 14:51
zerof: ProcessPoolExecutor 05/02 10:55