Collects elements in fixed-length chunks.
512392
def chunks(cls, iterable, n, fill=None):
    

    return cls(itertools.zip_longest(*[iter(iterable)] * n, fillvalue=fill))
1168517
async def chunks(source, n):
    
    async with streamcontext(source) as streamer:
        async for first in streamer:
            xs = select.take(create.preserve(streamer), n-1)
            yield [first] + await aggregate.list(xs)
1060760
def iter_chunks(l, size):
    
    if isinstance(l, six.integer_types):
        l = six.moves.range(l)

    if is_lazy_iterable(l):
        if size < 1:
            yield list(l)
        else:
            chunk = []
            for elem in l:
                if len(chunk) < size:
                    chunk.append(elem)
                else:
                    yield chunk
                    chunk = [elem]
            else:
                if chunk:
                    yield chunk

    else:
        if size < 1:
            yield l
        else:
            for i in six.moves.range(0, len(l), size):
                yield l[i:i + size]
835546
def _chunk(self, size):
        
        items = self.items

        return [items[i:i + size] for i in range(0, len(items), size)]
887405
def _GenerateChunk(self, length):
    """"""

    while 1:
      to_read = min(length, self.RECV_BLOCK_SIZE)
      if to_read == 0:
        return

      data = self.rfile.read(to_read)
      if not data:
        return

      yield data
      length -= len(data)
1298019
def _chunkForSend(self, data):
        
        LIMIT = self.CHUNK_LIMIT
        for i in range(0, len(data), LIMIT):
            yield data[i:i + LIMIT]
272650
def gather(input):
		""""""
		
		try:
			line = input.next()
		except StopIteration:
			return
		
		lead = True
		buffer = []
		
		# Gather contiguous (uninterrupted) lines of template text.
		while line.kind == 'text':
			value = line.line.rstrip().rstrip('\\') + ('' if line.continued else '\n')
			
			if lead and line.stripped:
				yield Line(line.number, value)
				lead = False
			
			elif not lead:
				if line.stripped:
					for buf in buffer:
						yield buf
					
					buffer = []
					yield Line(line.number, value)
				
				else:
					buffer.append(Line(line.number, value))
			
			try:
				line = input.next()
			except StopIteration:
				line = None
				break
			
		if line:
			input.push(line)
902216
def chunks(l, n):
    
    newn = int(1.0 * len(l) / n + 0.5)
    for i in range(0, n - 1):
        yield l[i * newn:i * newn + newn]
    yield l[n * newn - newn:]
145692
def chunks(iterable, size=100):
    
    it = iter(iterable)
    size -= 1
    for head in it:
        yield itertools.chain([head], itertools.islice(it, size))
1062197
def chunks(data, n):
    """"""
    for i in range(0, len(data), n):
        yield data[i:i+n]
293093
def chunk_list(l, n):
    """"""
    return [l[i:i + n] for i in range(0, len(l), n)]
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)))
238953
def chunks(seq, size):
    
    return (seq[pos:pos + size] for pos in range(0, len(seq), size))
1199140
def chunks(stream, chunk_size, output_type=tuple):
    '''  '''
    assert iterable(stream), 'chunks needs stream to be iterable'
    assert (isinstance(chunk_size, int) and chunk_size > 0) or callable(chunk_size), 'chunks needs chunk_size to be a positive int or callable'
    assert callable(output_type), 'chunks needs output_type to be callable'
    if callable(chunk_size):
        ''' chunk_size is acting as a separator function '''
        for chunk in chunk_on(stream, chunk_size, output_type):
            yield chunk
    else:
        it = iter(stream)
        marker = object()
        iters = [it] * chunk_size
        pipeline = apply_to_last(
           zip_longest(*iters, fillvalue=marker),
           lambda last_chunk: tuple(i for i in last_chunk if i is not marker)
        )
        if output_type is not tuple:
            pipeline = map(output_type, pipeline)
        for chunk in pipeline:
            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)
    )
1196588
def iter_chunks(chunksize, *iterables):
    """"""
    iterables = iter(zip(*iterables))

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

        if not chunk:
            return

        yield chunk
903009
def chunks(items, size):
    
    return [items[i:i+size] for i in range(0, len(items), size)]