-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Labels
Description
pathlib.Path.glob() converts a given string pattern to a Path object:
Lines 644 to 645 in dcae5cd
| if not isinstance(pattern, PurePath): | |
| pattern = self.with_segments(pattern) |
Which has the following drawbacks:
- It instantiates a
Pathobject, which is slow - It normalizes a Windows UNC drive if given, which is unnecessary - any anchor causes
NotImplementedErrorto be raised. - It strips the trailing slash from the pattern, so we need to peek at
pattern._raw_pathto restore it
It would be better to add a variant of PurePath._parse_path() for dealing specifically with glob patterns.
Linked PRs
tomasr8 and nineteendo