Splits iterator in chunks.
554887
def chunks(iterable, size=1):
    """"""
    iterator = iter(iterable)

    for element in iterator:
        yield chain([element], islice(iterator, size - 1))
512392
def chunks(cls, iterable, n, fill=None):
    

    return cls(itertools.zip_longest(*[iter(iterable)] * n, fillvalue=fill))
1362751
def _walk_through_splits(self):
        
        def walk(split):
            for c in split:
                if isinstance(c, (HSplit, VSplit)):
                    yield split, c
                    for i in walk(c):
                        yield i

        return walk(self.root)
1193956
def filechunk(f, chunksize):
    """"""
    while True:
        chunk = tuple(itertools.islice(f, chunksize))
        if not chunk:
            return
        yield np.loadtxt(iter(chunk), dtype=np.float64)
494731
async def iter_lines(self, chunk_size=1024):
        
        pending = b''
        async for chunk in self.iter_chunks(chunk_size):
            lines = (pending + chunk).splitlines(True)
            for line in lines[:-1]:
                await yield_(line.splitlines()[0])
            pending = lines[-1]
        if pending:
            await yield_(pending.splitlines()[0])
1151003
def _chunks(iterable, n):
    
    iterable = iter(iterable)
    while True:
        # store one line in memory,
        # chain it to an iterator on the rest of the chunk
        yield chain([next(iterable)], islice(iterable, n-1))
171728
def chunks(raw):
    """"""
    for i in range(0, len(raw), EVENT_SIZE):
        yield struct.unpack(EVENT_FORMAT, raw[i:i+EVENT_SIZE])
166690
def _MultiStream(cls, fds):
    """"""
    for fd in fds:
      fd.Seek(0)
      while True:
        chunk = fd.Read(cls.MULTI_STREAM_CHUNK_SIZE)
        if not chunk:
          break
        yield fd, chunk, None
1337142
def iter_slices(string, slice_length):
    """"""
    pos = 0
    if slice_length is None or slice_length <= 0:
        slice_length = len(string)
    while pos < len(string):
        yield string[pos:pos + slice_length]
        pos += slice_length
19470
private static Iterable<List<Map.Entry<Symbol, File>>> splitToNChunks(
      final ImmutableMap<Symbol, File> inputMap, int numChunks) {
    checkArgument(numChunks > 0);
    final List<Map.Entry<Symbol, File>> emptyChunk = ImmutableList.of();

    if (inputMap.isEmpty()) {
      return Collections.nCopies(numChunks, emptyChunk);
    }

    final int chunkSize = IntMath.divide(inputMap.size(), numChunks, RoundingMode.UP);
    final ImmutableList<List<Map.Entry<Symbol, File>>> chunks =
        ImmutableList.copyOf(splitToChunksOfFixedSize(inputMap, chunkSize));
    if (chunks.size() == numChunks) {
      return chunks;
    } else {
      // there weren't enough elements to make the desired number of chunks, so we need to
      // pad with empty chunks
      final int shortage = numChunks - chunks.size();
      final List<List<Map.Entry<Symbol, File>>> padding = Collections.nCopies(shortage, emptyChunk);
      return Iterables.concat(chunks, padding);
    }
  }
412562
def chunks(iterable, chunksize, cast=tuple):
    # type: (Iterable, int, Callable) -> Iterable
    
    it = iter(iterable)
    while True:
        yield cast(itertools.chain([next(it)],
                   itertools.islice(it, chunksize - 1)))
1196588
def iter_chunks(chunksize, *iterables):
    """"""
    iterables = iter(zip(*iterables))

    while 1:
        chunk = tuple(islice(iterables, chunksize))

        if not chunk:
            return

        yield chunk
548369
def chunk(iterable, chunk_size=20):
    """"""
    items = []
    for value in iterable:
        items.append(value)
        if len(items) == chunk_size:
            yield items
            items = []
    if items:
        yield items
861782
def split_input(cls, mapper_spec):
    """"""
    filelists = mapper_spec.params[cls.FILES_PARAM]
    max_values_count = mapper_spec.params.get(cls.MAX_VALUES_COUNT_PARAM, -1)
    max_values_size = mapper_spec.params.get(cls.MAX_VALUES_SIZE_PARAM, -1)
    return [cls([0] * len(files), max_values_count, max_values_size)
            for files in filelists]
125611
def group_iter(iterator, n=2):
    

    # Use slices instead of an iterator when we have a flat list
    if isinstance(iterator, list):

        length = len(iterator)
        for i in range(int(math.ceil(old_div(float(length), n)))):
            yield iterator[i * n: (i + 1) * n]

    else:
        accumulator = []
        for item in iterator:
            accumulator.append(item)
            if len(accumulator) == n:
                yield accumulator
                accumulator = []

        # Yield what's left
        if len(accumulator) != 0:
            yield accumulator
1361515
def chunks(l: List[Any], n: int) -> Iterable[List[Any]]:
    
    for i in range(0, len(l), n):
        yield l[i:i + n]
854133
def chunker(l, n):
    
    for i in ranger(0, len(l), n):
        yield l[i:i + n]