def vectorize(f):
def vf(obj, *args, **kwargs):<EOL><INDENT>if hasattr(obj, '<STR_LIT>'):<EOL><INDENT>return obj.__distob_vectorize__(f)(obj, *args, **kwargs)<EOL><DEDENT>if isinstance(obj, Remote):<EOL><INDENT>return call(f, obj, *args, **kwargs)<EOL><DEDENT>elif distob._have_numpy and (isinstance(obj, np.ndarray) or<EOL>hasattr(type(obj), '<STR_LIT>')):<EOL><INDENT>distarray = scatter(obj, axis=-<NUM_LIT:1>)<EOL>return vf(distarray, *args, **kwargs)<EOL><DEDENT>elif isinstance(obj, collections.Sequence):<EOL><INDENT>inputs = scatter(obj)<EOL>dv = distob.engine._client[:]<EOL>kwargs = kwargs.copy()<EOL>kwargs['<STR_LIT>'] = False<EOL>results = []<EOL>for obj in inputs:<EOL><INDENT>results.append(call(f, obj, *args, **kwargs))<EOL><DEDENT>for i in range(len(results)):<EOL><INDENT>results[i] = convert_result(results[i])<EOL><DEDENT>return results<EOL><DEDENT><DEDENT>if hasattr(f, '<STR_LIT>'):<EOL><INDENT>vf.__name__ = '<STR_LIT:v>' + f.__name__<EOL>f_str = f.__name__ + '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>f_str = '<STR_LIT>'<EOL><DEDENT>doc = u"""<STR_LIT>""" % (f_str, f_str)<EOL>if hasattr(f, '<STR_LIT>') and f.__doc__ is not None:<EOL><INDENT>doc = doc.rstrip() + ('<STR_LIT>' + f.__doc__)<EOL><DEDENT>vf.__doc__ = doc<EOL>return vf<EOL>
Upgrade normal function f to act in parallel on distibuted lists/arrays

    Args:
      f (callable): an ordinary function which expects as its first argument a
        single object, or a numpy array of N dimensions.

    Returns:
      vf (callable): new function that takes as its first argument a list of
        objects, or a array of N+1 dimensions. ``vf()`` will do the
        computation ``f()`` on each part of the input in parallel and will
        return a list of results, or a distributed array of results.