26 lines
384 B
Python
26 lines
384 B
Python
|
"""
|
||
|
Pool
|
||
|
"""
|
||
|
from multiprocessing import Pool
|
||
|
|
||
|
def cubo(numero):
|
||
|
return numero * numero * numero
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
|
||
|
numeros = range(10)
|
||
|
pool = Pool()
|
||
|
|
||
|
# map, apply, join, close
|
||
|
result = pool.map(cubo, numeros)
|
||
|
# pool.apply(cubo, numeros[0])
|
||
|
|
||
|
pool.close()
|
||
|
pool.join()
|
||
|
|
||
|
print(result)
|
||
|
|
||
|
"""
|
||
|
[0, 1, 8, 27, 64, 125, 216, 343, 512, 729]
|
||
|
"""
|