Skip to content

[3.12] gh-153030: Fix quadratic complexity in incremental parsing in HTMLParser (GH-153031)#153041

Open
miss-islington wants to merge 1 commit into
python:3.12from
miss-islington:backport-bcf98dd-3.12
Open

[3.12] gh-153030: Fix quadratic complexity in incremental parsing in HTMLParser (GH-153031)#153041
miss-islington wants to merge 1 commit into
python:3.12from
miss-islington:backport-bcf98dd-3.12

Conversation

@miss-islington

@miss-islington miss-islington commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

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

…TMLParser (pythonGH-153031)

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants