'Like `imap()` method but ordering of results is arbitrary'

def imap_unordered(self, func, iterable, chunksize=1):

    if (chunksize == 1):
        result = IMapUnorderedIterator(self._cache)
        self._taskqueue.put((((result._job, i, func, (x,), {}) for (i, x) in enumerate(iterable)), result._set_length))
        return result
    else:
        task_batches = Pool._get_tasks(func, iterable, chunksize)
        result = IMapUnorderedIterator(self._cache)
        self._taskqueue.put((((result._job, i, mapstar, (x,), {}) for (i, x) in enumerate(task_batches)), result._set_length))
        return (item for chunk in result for item in chunk)
