◐ Shell
clean mode source ↗

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 barneygale changed the title Optimize pathlib.Path.glob() handling of ../ pattern segments GH-104102: Optimize pathlib.Path.glob() handling of ../ pattern segments

May 2, 2023

AlexWaygood

@AlexWaygood

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) + "*").

AlexWaygood

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.

@barneygale

carljm added a commit to carljm/cpython that referenced this pull request

May 2, 2023