4 ms·
This is neat! img = ["r", "g", "b"] * 10_000_000 iterator= iter(img) groups= zip(iterator, iterator, iterator) I've been writing Python for 15 years and
by da39a3ee 3y ago
This is neat!
img = ["r", "g", "b"] * 10_000_000
iterator= iter(img)
groups= zip(iterator, iterator, iterator)
I've been writing Python for 15 years and it had never occurred to me that I could do it like that. Honestly I think I'd have reached for more_itertools.chunked.
(FWIW In R I think I used to set an array dimension on the vector and process rows.)