Skip to content

gh-159739: Avoid quadratic grouped-address parsing - #159990

Merged
JelleZijlstra merged 1 commit into
python:mainfrom
jelle-openai:jelle/codex/gh-159739-email-addresslist-growth
Oct 21, 2026
Merged

JelleZijlstra merged 1 commit into
python:mainfrom
jelle-openai:jelle/codex/gh-159739-email-addresslist-growth

Conversation

@jelle-openai

@jelle-openai jelle-openai commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Avoid quadratic grouped-address parsing. email.utils.getaddresses() parses a group by repeatedly concatenating the accumulated address list with each newly parsed member. Each concatenation copies all prior entries, so a group with many members takes quadratic time and can consume excessive CPU. Extending the list in place avoids that repeated copying.

Backport to 3.15 and 3.14.

@jelle-openai
jelle-openai requested a review from a team as a code owner October 20, 2026 23:23
@JelleZijlstra

Copy link
Copy Markdown
Member

Not going to backport this as it's a performance improvement.

@JelleZijlstra
JelleZijlstra enabled auto-merge (squash) October 21, 2026 18:46
@JelleZijlstra
JelleZijlstra merged commit 080fc54 into python:main Oct 21, 2026
104 of 106 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants