[issue19993] Pool.imap doesn't work as advertised

Jurjen N.E. Bos report at bugs.python.org
Mon Dec 16 09:31:16 CET 2013


New submission from Jurjen N.E. Bos:

The pool.imap and pool.imap_unordered functions are documented as "a lazy version of Pool.map".
In fact, they aren't: they consume the iterator argument as a whole. This is almost certainly not what the user wants: it uses unnecessary memory and will be slower than expected if the output iterator isn't consumed in full. In fact, there isn't much use at all of imap over map at the moment.
I tried to fixed the code myself, but due to the two-level queueing of the input arguments this is not trivial.
Stackoverflow's Blckknght wrote a simplified solution that gives the idea how it should work.
Since that wasn't posted here, I thought it would be useful to put it here, even if only for documentation purposes.

----------
components: Library (Lib)
files: mypool.py
messages: 206279
nosy: jneb
priority: normal
severity: normal
status: open
title: Pool.imap doesn't work as advertised
type: behavior
Added file: http://bugs.python.org/file33158/mypool.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19993>
_______________________________________


More information about the Python-bugs-list mailing list