Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
The map operation is a typical concept from the functional programming paradigm. However, side-effects are a typical example of something that does not fit functional programming well. As a resul...
Answer
#1: Initial revision
The `map` operation is a typical concept from the functional programming paradigm. However, side-effects are a typical example of something that does not fit functional programming well. As a result, `map` is probably not what you want to use. As an alternative, you can just use the [`apply`](https://docs.python.org/3/library/multiprocessing.html#multiprocessing.pool.Pool.apply) method of the `Pool` class as follows: ```python import multiprocessing pool = multiprocessing.Pool for f_i in f: pool.apply(f_i) ``` Given that your context seems to be IO-bound, it might also be useful to consider thread pools instead of process pools. Threads are a bit more lightweight, but due to the [GIL](https://wiki.python.org/moin/GlobalInterpreterLock) they are only useful for tasks where the CPU has to wait for IO anyway. ```python from concurrent.futures import ThreadPoolExecutor with ProcessPoolExecutor() as pool: for f_i in f: pool.submit(f_i) ``` FYI: the `concurrent.futures` package also has a ProcessPoolExecutor with the same interface.