[issue25870] textwrap is very slow on long words without spaces

2015-12-15 Thread Bernhard M. Wiedemann
Bernhard M. Wiedemann added the comment: should probably be lines = [x[n*64:(n+1)*64] for n in range(((len(x)-1)//64)+1)] to avoid an empty line added when the last line is full which once again shows why people prefer to use standard libraries for this kind of work --

[issue25870] textwrap is very slow on long words without spaces

2015-12-15 Thread R. David Murray
R. David Murray added the comment: This has already been fixed in issue 22687. It was deemed a performance improvement for an edge case and was not backported. I don't see the advantage of using textwrap to split up base64 encoded strings, by the way. The module isn't designed for doing

[issue25870] textwrap is very slow on long words without spaces

2015-12-15 Thread Martin Panter
Martin Panter added the comment: There is a standard library fuction for that ;) the step argument to range(): lines = (result[n:n + 64] for n in range(0, len(result), 64)) -- nosy: +martin.panter ___ Python tracker

[issue25870] textwrap is very slow on long words without spaces

2015-12-15 Thread Bernhard M. Wiedemann
New submission from Bernhard M. Wiedemann: Many python scripts use textwrap to break base64-encoded strings from openssl into lines - e.g. https://bugs.launchpad.net/python-keystoneclient/+bug/1404402 and https://github.com/diafygi/acme-tiny/blob/master/acme_tiny.py#L166 Steps To Reproduce:

[issue25870] textwrap is very slow on long words without spaces

2015-12-15 Thread R. David Murray
R. David Murray added the comment: Oh, good call. I forgot about step. -- ___ Python tracker ___ ___