Speed up case sensitive is-file check in file system cache - #10093
Merged
Conversation
This speeds up resolving imports somewhat. Add fast paths to `isfile_case`. On Linux we skip all logic, since the file system is almost always case sensitive. Cache results of parent directories as well. Add tests.
ilevkivskyi
approved these changes
Feb 15, 2021
| self.make_file('bar.py') | ||
| self.make_file('pkg/sub_package/__init__.py') | ||
| self.make_file('pkg/sub_package/foo.py') | ||
| # Run twice to test bost cached and non-cached code paths. |
| assert self.isfile_case('pkg/sub_package/__init__.py') | ||
| assert self.isfile_case('pkg/sub_package/foo.py') | ||
| assert not self.isfile_case('non_existent.py') | ||
| assert not self.isfile_case('pkg/non_existent.py') |
Member
There was a problem hiding this comment.
Maybe add a third test case where you check the two intermingled? For example:
- cold case-sensitive
- cold case-insensitive
- warm case-sensitive
- warm case-insensitive
| self.make_file('bar.py') | ||
| self.make_file('pkg/sub_package/__init__.py') | ||
| self.make_file('pkg/sub_package/foo.py') | ||
| # Run twice to test bost cached and non-cached code paths. |
hauntsaninja
pushed a commit
to hauntsaninja/mypy
that referenced
this pull request
Dec 10, 2021
Originally added in python#10093 Fixes python#11690, fixes python#10661, fixes python#10822
JukkaL
pushed a commit
that referenced
this pull request
Dec 13, 2021
tushar-deepsource
pushed a commit
to DeepSourceCorp/mypy
that referenced
this pull request
Jan 20, 2022
Originally added in python#10093 Fixes python#11690, fixes python#10661, fixes python#10822 Co-authored-by: hauntsaninja <>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This speeds up resolving imports somewhat.
Add fast paths to
isfile_case. On Linux we skip all logic, sincethe file system is almost always case sensitive.
Cache results of parent directories as well.
Add tests.