def pimap(iterable, function, *args, **kwargs):
 from multiprocessing import Pool
 global worker
 def worker(x):
  return function(x, *args, **kwargs)
 return Pool(processes=None).imap(worker, iterable)

def pimap ( iterable , function , * args , ** kwargs ) : from multiprocessing import Pool global worker def worker ( x ) : return function ( x , * args , ** kwargs ) return Pool ( processes = None ) . imap ( worker , iterable )
returns an iterator of function for the iterable .