def head(iterable, max=10):
    first = next(iterable)

def head_inner():
    yield first
for cnt, el in enumerate(iterable):
    yield el
if cnt + 1 >= max:
    break
return head_inner()
Split a generator into chunks without pre-walking it