我想使用配备 2 个四核处理器的 Mac Pro 并行化以下 python 循环。
result_list = []
for a in a_range:
for b in b_range:
for c in c_range:
result = call_fortran_program(a, b, c)
result_list.append(result)
在我的搜索中,我遇到过像 Cython 和 GIL 这样的术语,但我仍然不清楚如何继续。
请您参考如下方法:
from itertools import product
from multiprocessing import Pool
with Pool(processes=4) as pool: # assuming Python 3
pool.starmap(print, product(range(2), range(3), range(4)))
