gh-153030: Fix quadratic complexity in incremental parsing in HTMLParser#153031
Conversation
serhiy-storchaka
commented
Jul 4, 2026
- Issue: Another worst case quadratic complexity in HTMLParser #153030
…TMLParser When an unterminated construct (e.g. a tag or comment) spanned many feed() calls, rescanning the growing buffer and concatenating new data onto it were both quadratic. New data is now accumulated in a list and only joined and parsed once enough has piled up. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11, 3.12, 3.13, 3.14, 3.15. |
|
GH-153038 is a backport of this pull request to the 3.15 branch. |
|
GH-153039 is a backport of this pull request to the 3.14 branch. |
|
GH-153040 is a backport of this pull request to the 3.13 branch. |
|
Sorry, @serhiy-storchaka, I could not cleanly backport this to |
|
GH-153041 is a backport of this pull request to the 3.12 branch. |
|
Sorry, @serhiy-storchaka, I could not cleanly backport this to |
|
GH-153042 is a backport of this pull request to the 3.11 branch. |
|
GH-153043 is a backport of this pull request to the 3.10 branch. |
…HTMLParser (GH-153031) (GH-153040) When an unterminated construct (e.g. a tag or comment) spanned many feed() calls, rescanning the growing buffer and concatenating new data onto it were both quadratic. New data is now accumulated in a list and only joined and parsed once enough has piled up. (cherry picked from commit bcf98dd) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…HTMLParser (GH-153031) (GH-153039) When an unterminated construct (e.g. a tag or comment) spanned many feed() calls, rescanning the growing buffer and concatenating new data onto it were both quadratic. New data is now accumulated in a list and only joined and parsed once enough has piled up. (cherry picked from commit bcf98dd) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…HTMLParser (GH-153031) (GH-153038) When an unterminated construct (e.g. a tag or comment) spanned many feed() calls, rescanning the growing buffer and concatenating new data onto it were both quadratic. New data is now accumulated in a list and only joined and parsed once enough has piled up. (cherry picked from commit bcf98dd) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>