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

Two more micro-optimizations#19627

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
ilevkivskyi merged 1 commit intopython:masterfromilevkivskyi:twop-more-opts
Aug 9, 2025

Conversation

@ilevkivskyi
Copy link
Member

This has two things (totalling 1.5% locally, but see caveat below):

  • Do not use@contextmanger (that is relatively slow) forlocal_type_map, since it appears in multiple hot paths.
  • Do not show name suggestions for import errors in third party packages (since those errors are ignored anyway). It callsdifflib that can be extremely slow with large modules.

Btw the second will probably not affect self-check, although it did affectmy self-check, since apparentlypytest depends onnumpy. Well, they don't specify it as a package dependency, buthttps://github.com/pytest-dev/pytest/blob/main/src/_pytest/python_api.py#L17-L18

ifTYPE_CHECKING:fromnumpyimportndarray

(and I have numpy installed in all my environments, LOL)

@github-actions
Copy link
Contributor

According tomypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@ilevkivskyi
Copy link
MemberAuthor

Btw just wanted to brag about how stable is my local bench:

master                    3.810s (0.0%)  | stdev 0.008s twop-more-opts            3.756s (-1.4%) | stdev 0.008s

(you read that right, standard deviation is just 8 milliseconds)

sterliakov and hauntsaninja reacted with eyes emoji

Copy link
Collaborator

@sterliakovsterliakov left a comment

Choose a reason for hiding this comment

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

Nice one! Please post this to plugin API announcements - I expect some plugins in wild might use this functionality (yes, undocumented, yes, private, let's just do that and let people know something might break).

since apparently pytest depends on numpy

Nowthat was interesting.

@ilevkivskyiilevkivskyi merged commit660d911 intopython:masterAug 9, 2025
20 checks passed
@ilevkivskyiilevkivskyi deleted the twop-more-opts branchAugust 9, 2025 18:47
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@JukkaLJukkaLAwaiting requested review from JukkaL

@hauntsaninjahauntsaninjaAwaiting requested review from hauntsaninja

1 more reviewer

@sterliakovsterliakovsterliakov approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@ilevkivskyi@sterliakov

[8]ページ先頭

©2009-2025 Movatter.jp