-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-109653: Improve the import time of email.utils
#109824
Merged
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0aca553
WIP
AlexWaygood f3c815d
news
AlexWaygood 992274f
I can spell my own name
AlexWaygood 493aa33
Apply suggestions from code review
AlexWaygood a697d9d
Merge branch 'main' into email-message-import
AlexWaygood 03233f1
Abandon the separate submodule idea
AlexWaygood f11bc98
stats are slightly less impressive now because importing random is ch…
AlexWaygood c5e7a61
Merge branch 'email-message-import' of https://github.com/AlexWaygood…
AlexWaygood bcaeb4c
Merge branch 'main' into email-message-import
AlexWaygood b387dcd
Update Lib/email/utils.py
AlexWaygood c72ee5c
Merge branch 'main' of https://github.com/python/cpython into email-m…
AlexWaygood e201028
eagerly import os, it is free
AlexWaygood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
Misc/NEWS.d/next/Library/2023-09-25-10-47-22.gh-issue-109653.TUHrId.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Reduce the import time of :mod:`email.utils` by around 43%. This results in | ||
the import time of :mod:`email.message` falling by around 18%, which in turn | ||
reduces the import time of :mod:`importlib.metadata` by around 6%. Patch by | ||
Alex Waygood. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I like this one, only fine with it since
formataddr
doesn't look too widely used (a lot of the time it's nice to pay these costs upfront, predictable performance is important, e.g. don't want the first request your webserver serves to be randomly slow)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed. On the other hand, though, the
email
package goes in quite heavily for lazy imports in some other places, so this does seem in keeping with that general philosophy:cpython/Lib/email/__init__.py
Lines 28 to 61 in f786029
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be happy to change it so it's imported at the top of the function if you think that'd be better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah that'd be worse, module level or here. I'm fine with this as is!