Chunk data into max_size, yield each chunk, then return final chunk
973341
def chunk_data(payload, max_size)
      total = payload.bytesize
      cursor = 0
      while (total - cursor) > max_size
        yield payload.byteslice(cursor, max_size)
        cursor += max_size
      end
      payload.byteslice(cursor, total - cursor)
    end
803883
def chunk(self, iterable, n, fillvalue=None):
    ""
    # grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx
    args = [iter(iterable)] * n
    return izip_longest(fillvalue=fillvalue, *args)
1196588
def iter_chunks(chunksize, *iterables):
    """"""
    iterables = iter(zip(*iterables))

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

        if not chunk:
            return

        yield chunk
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)
    )
1267331
def _get_batches(self, items):
        """"""
        for i in xrange(0, len(items), self.max_batch_size):
            yield items[i:i + self.max_batch_size]
1231409
def chunked(data, chunksize):
    
    if chunksize < 1:
        raise ValueError("Chunksize must be at least 1!")
    if int(chunksize) != chunksize:
        raise ValueError("Chunksize needs to be an integer")
    res = []
    cur = []
    for e in data:
        cur.append(e)
        if len(cur) >= chunksize:
            res.append(cur)
            cur = []
    if cur:
        res.append(cur)
    return res
1064558
def chunks(container, n):
    
    for i in range(0, len(container), n):
        yield container[i : i + n]
813117
def chunk(iterator, max_size):
    
    gen = iter(iterator)
    while True:
        chunked = list()
        for i, item in enumerate(gen):
            chunked.append(item)
            if i >= max_size - 1:
                break
        if not chunked:
            return
        yield chunked
759280
def chunks(l:Collection, n:int)->Iterable:
    ""
    for i in range(0, len(l), n): yield l[i:i+n]
220421
def chunkiter(objs, n=100):
    

    objs = iter(objs)
    try:
        while (1):
            chunk = []
            while len(chunk) < n:
                chunk.append(six.next(objs))
            yield chunk
    except StopIteration:
        pass
    if len(chunk):
        yield chunk
1187954
def _file_chunks(self, data, chunk_size):
        
        for i in xrange(0, len(data), chunk_size):
            yield self.compressor(data[i:i+chunk_size])
171728
def chunks(raw):
    """"""
    for i in range(0, len(raw), EVENT_SIZE):
        yield struct.unpack(EVENT_FORMAT, raw[i:i+EVENT_SIZE])
403628
def data_chunk(data, chunk, with_overlap=False):
    """"""
    assert isinstance(chunk, tuple)
    if len(chunk) == 2:
        i, j = chunk
    elif len(chunk) == 4:
        if with_overlap:
            i, j = chunk[:2]
        else:
            i, j = chunk[2:]
    else:
        raise ValueError("'chunk' should have 2 or 4 elements, "
                         "not {0:d}".format(len(chunk)))
    return data[i:j, ...]
366506
def pieces(array, chunk_size):
        """"""
        for i in range(0, len(array), chunk_size): yield array[i:i+chunk_size]
145692
def chunks(iterable, size=100):
    
    it = iter(iterable)
    size -= 1
    for head in it:
        yield itertools.chain([head], itertools.islice(it, size))
346050
def chunks(iterable, n):
    
    for i in range(0, len(iterable), n):
        yield iterable[i:i + n]
1180232
def read_in_chunks(file_object, chunk_size=CHUNK_SIZE):
    """"""
    while True:
        data = file_object.read(chunk_size)
        if not data:
            break
        yield data