Skip to content

gh-153030: Fix quadratic complexity in incremental parsing in HTMLParser - #153031

Merged
serhiy-storchaka merged 2 commits into
python:mainfrom
serhiy-storchaka:htmlparser-feed-throttle
Jul 4, 2026
Merged

serhiy-storchaka merged 2 commits into
python:mainfrom
serhiy-storchaka:htmlparser-feed-throttle

Conversation

…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>
@serhiy-storchaka
serhiy-storchaka merged commit bcf98dd into python:main Jul 4, 2026
54 checks passed
@miss-islington-app

Copy link
Copy Markdown

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.
🐍🍒⛏🤖

@serhiy-storchaka
serhiy-storchaka deleted the htmlparser-feed-throttle branch July 4, 2026 17:40
@bedevere-app

bedevere-app Bot commented Jul 4, 2026

Copy link
Copy Markdown

GH-153038 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Jul 4, 2026
@bedevere-app

bedevere-app Bot commented Jul 4, 2026

Copy link
Copy Markdown

GH-153039 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jul 4, 2026
@bedevere-app

bedevere-app Bot commented Jul 4, 2026

Copy link
Copy Markdown

GH-153040 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Jul 4, 2026
@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker bcf98ddbc40ec9b3ee87da0124a5660b19b7e606 3.11
@bedevere-app

bedevere-app Bot commented Jul 4, 2026

Copy link
Copy Markdown

GH-153041 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Jul 4, 2026
@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker bcf98ddbc40ec9b3ee87da0124a5660b19b7e606 3.10
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