[Python-ideas] pmap, preduce, pmapreduce?

Masklinn masklinn at masklinn.net
Sat May 26 17:34:52 CEST 2012


On 2012-05-25, at 23:37 , Mike Meyer wrote:
> 
> Is it possible to place limitations on the function such that this
> kind of controlled concurrent operation is safe?

This would mean ideally only having pure functions, and at the very
least having functions which can't share state (not easily anyway).

Python, as a language, has no such provision that I know of beyond "be
careful" and "you're on your own".

A possible option, though, would be to use `multiprocessing` rather than
threads: multiprocessing.pool already provides a `map` operation, and
processes can't share state by default (doing so is quite an explicit
— and some would say involved — operation). Going through
multiprocessing puts other limitations/complexities on the function
implementations, but at the very least it wouldn't be possible to
*unknowingly* share state.


More information about the Python-ideas mailing list