Skip to content

gh-137855: Improve import time of dataclasses by lazy importing re and copy modules#148379

Merged
hugovk merged 7 commits intopython:mainfrom
danielhollas:dataclass-lazy-re
Apr 11, 2026
Merged

gh-137855: Improve import time of dataclasses by lazy importing re and copy modules#148379
hugovk merged 7 commits intopython:mainfrom
danielhollas:dataclass-lazy-re

Conversation

@danielhollas
Copy link
Copy Markdown
Contributor

@danielhollas danielhollas commented Apr 11, 2026

Split from #144387 as requested by @hugovk (tagging for review :-) This is a relatively minor win, the bigger win will come from lazy importing inspect in #144387

See below for tuna-visualized outputs from ./python -X importtime -c "import dataclasses"
(the absolute import numbers are not representative as I was running a debug python build)

Before

image

After

image

danielhollas and others added 4 commits April 11, 2026 17:19
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
@danielhollas
Copy link
Copy Markdown
Contributor Author

The failing Ubuntu build is a transient issue during dependency installation that will hopefully go away when the job is restarted.

Copy link
Copy Markdown
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@hugovk hugovk enabled auto-merge (squash) April 11, 2026 20:47
@hugovk hugovk merged commit dd2735d into python:main Apr 11, 2026
97 of 99 checks passed
@danielhollas danielhollas deleted the dataclass-lazy-re branch April 11, 2026 21:12
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