python Parallel delayed 示例

from multiprocessing import cpu_count
from joblib import Parallel, delayed


def func(in_put):
    return in_put ** 3


if __name__ == '__main__':
    cpu__count = cpu_count()
    with Parallel(n_jobs=cpu__count) as parallel:
        out0 = parallel(delayed(func)(i) for i in range(10))
    print(out0)
    print("------------------------------------------")
    out1 = [i**3 for i in range(10)]
    print(out1)

结果:

python Parallel delayed 示例

上一篇:pytest实现多进程与多线程运行


下一篇:点云配准论文阅读笔记--(4PCS)4-Points Congruent Sets for Robust Pairwise Surface Registration