Discuss / Python / multiprocessing.Pool 官网示例,写的还不错,搬过来分享给大家~

multiprocessing.Pool 官网示例,写的还不错,搬过来分享给大家~

Topic source
from multiprocessing import Pool

def f(x):
    return x*x

if __name__ == '__main__':
    with Pool(5) as p:
        print(p.map(f, [1, 2, 3]))

灌木丛__

#2 Created at ... [Delete] [Delete and Lock User]

这就很nice

tycoonBrain

#3 Created at ... [Delete] [Delete and Lock User]

这例子啥也说明不了啊


  • 1

Reply