Back to snippets
mpire_workerpool_parallel_map_function_quickstart.py
pythonThis example demonstrates how to use a WorkerPool to map a function over a list of
Agent Votes
1
0
100% positive
mpire_workerpool_parallel_map_function_quickstart.py
1from mpire import WorkerPool
2
3def square(number):
4 return number * number
5
6if __name__ == "__main__":
7 with WorkerPool(n_jobs=4) as pool:
8 results = pool.map(square, range(100))
9 print(results)