[issue22687] horrible performance of textwrap.wrap() with a long word

Serhiy Storchaka report at bugs.python.org
Tue Oct 21 20:09:14 CEST 2014


Serhiy Storchaka added the comment:

This particular case is related to the behavior of the wordsep_re regular expression in worst case. When text contains long sequence of words characters which is not ended by a hypen, or long sequence of non-word and non-space characters (and in some other cases), computational complexity of this regular expression matching is quadratic. This is a peculiarity of current implementation of regular expression engine. May be it is possible to rewrite the regular expression so that quadratic complexity will gone, but this is not so easy.

The workaround -- use break_on_hyphens=False.

----------
assignee:  -> serhiy.storchaka
priority: normal -> low
stage:  -> needs patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22687>
_______________________________________


More information about the Python-bugs-list mailing list