Yield successive n-sized chunks from iterable object. https://stackoverflow.com/a/312464
346050
def chunks(iterable, n):
    
    for i in range(0, len(iterable), n):
        yield iterable[i:i + n]
1223618
def chunks_of(max_chunk_size, list_to_chunk):
    
    for i in range(0, len(list_to_chunk), max_chunk_size):
        yield list_to_chunk[i:i + max_chunk_size]
254010
def i_batch(max_size, iterable):
    
    iterable_items = iter(iterable)
    for items_batch in iter(lambda: tuple(islice(iterable_items, max_size)),
                            tuple()):
        yield items_batch
733240
def chunks(l, n):
    
    newn = int(len(l) / n)
    for i in xrange(0, n-1):
        yield l[i*newn:i*newn+newn]
    yield l[n*newn-newn:]
1082165
def grouper(iterable, n):
    
    it = iter(iterable)
    while True:
        chunk = itertools.islice(it, n)
        try:
            first = next(chunk)
        except StopIteration:
            return

        yield itertools.chain([first], chunk)
1055191
def chunks(iterable, size):
    
    it = iter(iterable)
    item = list(islice(it, size))
    while item:
        yield item
        item = list(islice(it, size))
1193770
def ichunk(iterable, n):
  
  it = iter(iterable)
  while True:
    chunk = tuple(itertools.islice(it, n))
    if not chunk:
      return
    yield chunk
173448
def slice_into_pieces(seq, n):
    """"""
    length = len(seq)
    if length % n == 0:
        size = length // n
    else:
        size = length // n + 1
    for it in slice_by_size(seq, size):
        yield it
160844
def _chunk(iterable, size):
    """"""
    # We're going to use some star magic to chunk the iterable. We create a
    # copy of the iterator size times, then pull a value from each to form a
    # chunk. The last chunk may have some trailing Nones if the length of the
    # iterable isn't a multiple of size, so we filter them out.

    args = (iter(iterable),) * size

    return (
        # pylint: disable=star-args
        itertools.takewhile(lambda x: x is not None, group)
        for group in itertools.zip_longest(*args)
    )
50774
def chunks(items, chunksize):
    """"""

    items = iter(items)
    for first in items:
        chunk = chain((first,), islice(items, chunksize - 1))
        yield chunk
        deque(chunk, 0)
1078548
def chunks(data, size):
    
    for i in range(0, len(data), size):
        yield data[i:i + size]
760622
def chunks(lista, size):
    """"""
    if not isinstance(lista, list):
        logger.error('Erron in chunks, arg introduced is not a list.', lista=lista)
        return lista

    for i in range(0, len(lista), size):
        yield lista[i:i + size]
1112883
def chunks(some_list: List, n: int) -> Iterable[List]:
    """"""
    for i in range(0, len(some_list), n):
        yield some_list[i:i + n]
810174
def batch_iterable(l, n):
    ''' '''
    i = iter(l)
    piece = list(islice(i, n))
    while piece:
        yield piece
        piece = list(islice(i, n))
1178614
def list_chunks(l, n):
    
    if n < 1:
        n = 1
    return [l[i:i + n] for i in range(0, len(l), n)]
854133
def chunker(l, n):
    
    for i in ranger(0, len(l), n):
        yield l[i:i + n]
1206956
def _chunked(iterable, n):
    
    it = iter(iterable)
    while True:
        chunk = list(islice(it, n))
        if chunk:
            yield chunk
        else:
            return