3 ms·
Joining Strings in Python: A "Huh" Moment
- compressedgas 2y agoIf 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.