3 Aug
2011
3 Aug
'11
3:39 p.m.
The top of the recipe section in the itertools documentation says: "The superior memory performance is kept by processing elements one at a time rather than bringing the whole iterable into memory all at once." but itertools.ncycles doesn't really. It's one line, so I'll inline it here: def ncycles(iterable, n): return chain.from_iterable(repeat(tuple(iterable), n)) Somewhere along the line something was going to need to buffer that, but it'd be nicer if the example didn't have the buffering done all at once at the outset as it is now. Perhaps more importantly, though, is there a specific objection to just adding a count to itertools.cycle much like itertools.repeat has now for this? Thanks. JB