Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-132952: Import _io instead of io at startup#132957

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JelleZijlstra merged 6 commits intopython:mainfromJelleZijlstra:sunder-io
Apr 28, 2025

Conversation

JelleZijlstra
Copy link
Member

@JelleZijlstraJelleZijlstra commentedApr 25, 2025
edited by bedevere-appbot
Loading

@JelleZijlstra
Copy link
MemberAuthor

Like#132956 this only helps-S startup becauseio gets imported anyway by site.py and possibly other places. Maybe we can make those other places also use_io but not convinced it's worth it.

@mdboom
Copy link
Contributor

I'm going to run this branch on our benchmarking hardware (as well as#132956), just so we have some numbers.

@mdboom
Copy link
Contributor

Benchmarking of this PR:https://github.com/faster-cpython/benchmarking-public/blob/main/results/bm-20250425-3.14.0a7%2B-dac50cc/bm-20250425-linux-x86_64-JelleZijlstra-sunder_io-3.14.0a7%2B-dac50cc-vs-base.svg

This is actually more effective than (19%) than#132956 (12%). I think it makes sense to merge this, and maybe the other just for good measure (though it should have no additional effect).

@JelleZijlstra
Copy link
MemberAuthor

This is now ready.

One tricky aspect is that we need to check any side effects that come from importingio. Most of the file is defining ABCs and registering things to those ABCs; it's fine if we omit that because the ABCs don't exist if the module isn't imported. However, it also sets the__module__ attribute on theUnsupportedOperation exception. I changed the code to set that attribute in_io instead because otherwise users who never importio would see this exception with the wrong module name.

@@ -0,0 +1,2 @@
Speed up startup with the ``-S`` argument by about 19% by importing the
Copy link
Member

Choose a reason for hiding this comment

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

it is worth mentioning "vs what" when stating an improvement %.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's 19% vs. before this commit, but it's only 1.5% faster than 3.13.0 (which is probably what most users care about, since they don't runmain). I would argue 1.5% is in the noise, so we probably shouldn't have a what's new entry at all -- this is just counteracting a regression in 3.14 development.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

It's only a NEWS entry, not text in the What's New, so I'll remove the 19% claim but leave the NEWS entry since this could affect behavior some users care about.

mdboom reacted with thumbs up emoji
Copy link
Contributor

@mdboommdboom left a comment

Choose a reason for hiding this comment

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

LGTM, but I think we should remove the whatsnew.

@bedevere-app
Copy link

When you're done making the requested changes, leave the comment:I have made the requested changes; please review again.

@JelleZijlstra
Copy link
MemberAuthor

I have made the requested changes; please review again

@bedevere-app
Copy link

Thanks for making the requested changes!

@mdboom,@gpshead: please review the changes made to this pull request.

@JelleZijlstraJelleZijlstra merged commit58567cc intopython:mainApr 28, 2025
47 of 50 checks passed
@JelleZijlstraJelleZijlstra deleted the sunder-io branchApril 28, 2025 15:39
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@mdboommdboommdboom approved these changes

@FFY00FFY00Awaiting requested review from FFY00FFY00 is a code owner

@ericsnowcurrentlyericsnowcurrentlyAwaiting requested review from ericsnowcurrentlyericsnowcurrently is a code owner

@gpsheadgpsheadAwaiting requested review from gpshead

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@JelleZijlstra@mdboom@gpshead

[8]ページ先頭

©2009-2025 Movatter.jp