def pmap(f, iterable, n=None, dummy=False, p=None):
<EOL>if n == <NUM_LIT:1>:<EOL><INDENT>for r in it.starmap(f, iterable):<EOL><INDENT>yield r<EOL><DEDENT>raise StopIteration<EOL><DEDENT>if p is None:<EOL><INDENT>po = pool(n, dummy)<EOL><DEDENT>else:<EOL><INDENT>po = p<EOL><DEDENT>assert hasattr(po, '<STR_LIT>')<EOL>f = _func_star(f)<EOL>try:<EOL><INDENT>for r in po.imap(f, iterable):<EOL><INDENT>yield r<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>if p is None:<EOL><INDENT>try:<EOL><INDENT>po.close()<EOL>po.join()<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>
parallel map of a function to an iterable
if each item in iterable is itself an iterable, then
automatically call f(*item) instead of f(item)

Arguments:
  f: function
  iterable: any iterable where each item is sent to f
  n: number of cpus (default is number on machine)
  dummy: use dummy pool.
  p: existing pool to re-use