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: time python -c "import textwrap; textwrap.wrap('x'*9000, 64)" This has a complexity of O(n^2), meaning wrapping 18000 chars takes 4 times as long as 9000. one known workaround is to use textwrap.wrap('x'*9000, 64, break_on_hyphens=False) this also has O(n^2) complexity, but is around 2000 times faster. ---------- components: Benchmarks, Extension Modules, Library (Lib), Regular Expressions messages: 256461 nosy: bmwiedemann, brett.cannon, ezio.melotti, mrabarnett, pitrou priority: normal severity: normal status: open title: textwrap is very slow on long words without spaces type: performance versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25870> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com