GH-104102: Optimize `pathlib.Path.glob()` handling of `../` pattern segments by barneygale · Pull Request #104103 · python/cpython
These segments do not require a `stat()` call, as the selector's `_select_from()` method is called after we've established that the parent is a directory.
barneygale
changed the title
Optimize
GH-104102: Optimize pathlib.Path.glob() handling of ../ pattern segmentspathlib.Path.glob() handling of ../ pattern segments
I think we could add some more tests here. There don't seem to be any tests for patterns with two successive .. segments, e.g. Path(".").glob("../../*"), or any test cases for "extreme" patterns, such as Path(".").glob(("../" * 50) + "*").
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fab to me other than my point about test coverage! Great work.
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