3 ms·
If the memory usage really matters, you would be better off replacing: '\n'.join(gen) with '\n'.join('\n'.join(w) for w in window(gen)) where window is a f
by compressedgas 2y ago
If the memory usage really matters, you would be better off replacing:
'\n'.join(gen) with '\n'.join('\n'.join(w) for w in window(gen))
where window is a function which yields sublists of some length perhaps dependent on the length of the elements.