|
|
Subscribe / Log in / New account

Advanced computing with IPython

Advanced computing with IPython

Posted Jun 5, 2018 15:14 UTC (Tue) by osma (subscriber, #6912)
Parent article: Advanced computing with IPython

Thank you for the informative article! It's great to hear about different ways of parallelizing Python code.

I've personally used the multiprocessing.Pool class to parallelize code execution. Combined with the "with" statement, it's a really easy way of executing code in parallel on multiple cores. For example:

inputs = [1, 2, 3, 4]

with multiprocessing.Pool(processes=4) as pool:
outputs = pool.map(slow_function, inputs)

This runs slow_function in four parallel processes, using a different value as input for each, and places the results in the outputs list.


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds