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

Make metas more compact; fix indirect suppression#20075

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 2 commits intopython:masterfromilevkivskyi:compact-metas
Oct 17, 2025

Conversation

@ilevkivskyi
Copy link
Member

This makes cache metas ~twice smaller with two things:

  • Don't store individual options that don't require any special handling, just take a hash of them all. This behavior is disabled if--debug-cache is set.
  • Storedep_hashes as a list instead of a dictionary.

Note that while implementing the second part, the assert I added failed, so I started digging and fond that suppression was handled inconsistency for indirect dependencies. I am fixing this here, now indirect dependencies are (un)suppressed just like any other dependency. Note this allowed to simplify/delete some parts of the code.

I the next PR I am going to use fixed format serialization forCacheMeta (when enabled).

@github-actions

This comment has been minimized.

current_options=manager.options.clone_for_module(id).select_options_affecting_cache()
current_options=options_snapshot(id,manager)
ifmanager.options.skip_version_check:
# When we're lax about version we're also lax about platform.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you explain this? It isn't a new line, but this behavior is really confusing to me. How "accept a cache generated by another mypy version" is related to "use cache for a potentially wrong platform"?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Unfortunately I don't have context on this decision, probably the idea is that--skip-version-check implies the user assumes manual control over the cache. Also this behaviour is there from 2017, so I guess those who use it, are fine with it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the motivation is that you can easily debug e.g. caches generated on Linux on a macOS development machine.--skip-version-check is designed to make debugging incremental issues easier -- e.g. you can ask a user to send a .tgz with a cache dump which reproduces some issue, and you can use that cache on your development machine, even if it has a different OS and you might not have the exact same mypy version (e.g. with local changes with a fix attempt).

sterliakov reacted with thumbs up emoji
Copy link
Collaborator

Choose a reason for hiding this comment

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

That's an interesting idea - I didn't even think of that. Nice catch!

Co-authored-by: Stanislav Terliakov <50529348+sterliakov@users.noreply.github.com>
@github-actions
Copy link
Contributor

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

Copy link
Collaborator

@JukkaLJukkaL left a comment

Choose a reason for hiding this comment

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

Nice, cache meta files were quite verbose, and were probably impacting performance in large incremental runs. I don't understand all the changes related to indirect dependencies, but since you probably have the best understanding of them at this point, I trust that the changes are reasonable.

current_options=manager.options.clone_for_module(id).select_options_affecting_cache()
current_options=options_snapshot(id,manager)
ifmanager.options.skip_version_check:
# When we're lax about version we're also lax about platform.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the motivation is that you can easily debug e.g. caches generated on Linux on a macOS development machine.--skip-version-check is designed to make debugging incremental issues easier -- e.g. you can ask a user to send a .tgz with a cache dump which reproduces some issue, and you can use that cache on your development machine, even if it has a different OS and you might not have the exact same mypy version (e.g. with local changes with a fix attempt).

sterliakov reacted with thumbs up emoji
Separately store only the options we may compare individually, and take a hash
of everything else. If --debug-cache is specified, fall back to full snapshot.
"""
snapshot=manager.options.clone_for_module(id).select_options_affecting_cache()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Random thing I noticed (no need to fix here, but could be useful to fix eventually if I'm right):clone_for_module does a bunch of caching to avoid repeated computation, butselect_options_affecting_cache recomputes everything on each call. I think a similar caching strategy would work for it, which might improve options processing performance. If you agree with this, I can create an issue about this. The caching should probably also cover `hash_digest(json_dumps(...)``.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yes, I think we should try this at some point, it may give visible speed-up for large builds (the method usesgetattr() in a loop, that may be slow).

@ilevkivskyiilevkivskyi merged commit37333c7 intopython:masterOct 17, 2025
20 checks passed
@ilevkivskyiilevkivskyi deleted the compact-metas branchOctober 17, 2025 18:16
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@JukkaLJukkaLJukkaL approved these changes

+1 more reviewer

@sterliakovsterliakovsterliakov left review comments

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.

3 participants

@ilevkivskyi@JukkaL@sterliakov

[8]ページ先頭

©2009-2025 Movatter.jp