遇见YY

导航

 
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)

结果:

posted on 2020-11-29 15:27  一骑红尘妃子笑!  阅读(1480)  评论(0编辑  收藏  举报