Skip to content

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

Merged
pablogsal merged 1 commit into
python:3.10from
serhiy-storchaka:backport-153030-3.10
Aug 10, 2026
Merged

pablogsal merged 1 commit into
python:3.10from
serhiy-storchaka:backport-153030-3.10

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

Manual backport of GH-153031 to 3.10.

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.

…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.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit bcf98dd)
@pablogsal
pablogsal merged commit 1e7956f into python:3.10 Aug 10, 2026
16 of 18 checks passed
@serhiy-storchaka
serhiy-storchaka deleted the backport-153030-3.10 branch August 27, 2026 12:13
icanhasmath pushed a commit to ActiveState/cpython that referenced this pull request Oct 28, 2026
…ng in HTMLParser (pythonGH-153031) (python#153043)

pythongh-153030: Fix quadratic complexity in incremental parsing in HTMLParser (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: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit 1e7956f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants