3 ms·
This crashed my computer (it's an infinite loop that needs too much memory, apparently), and there's a mistake (the i is not defined). Turns out that islice do
by StavrosK 13y ago
This crashed my computer (it's an infinite loop that needs too much memory, apparently), and there's a mistake (the i is not defined).
Turns out that islice doesn't raise an IterationError, it just returns an empty list.
Fixing the problems, it runs in 237 μsec per loop, around 23 times more than the zip version.
- signed0 13y agoHaha. I feel very silly now. I was just about to respond with the same thing. while True: result = list(islice(iterator, 3)) if not result: break yield result