Concurrent.futures: what are the use cases for map () vs. submit ()?

I am looking through the Python module concurrent.futures and using it to better familiarize myself with parallel / parallel programming models. Unfortunately, since this is a relatively new module, I can not find significant literature focused on beginners.

I understand that map () returns the direct return value of a function called iterable through processes or threads. And submit () returns a futures object.

I would like to receive a more detailed explanation of why this or that could be used. Map () seems to be more suited for clear parallel tasks that don't need to be coordinated. And submit () might be more useful for complex concurrent use cases. However, I'm pretty new to this, and hoped that someone more knowledgeable could expand.

Thanks.

+4
source share
1 answer

map used to call one function at one or several iterations. submit used to create a Future object for a single function call with its associated arguments.

Think of concurrent.map as a parallel version of the built-in map function. submit used to generate the future.

+2
source

All Articles