diff --git a/Lib/pathlib.py b/Lib/pathlib.py index 1498ce08be4012..db1c7c9618efbe 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -200,6 +200,7 @@ def make_uri(self, path): # Globbing helpers # +@functools.lru_cache() def _make_selector(pattern_parts, flavour): pat = pattern_parts[0] child_parts = pattern_parts[1:] @@ -215,9 +216,6 @@ def _make_selector(pattern_parts, flavour): cls = _PreciseSelector return cls(pat, child_parts, flavour) -if hasattr(functools, "lru_cache"): - _make_selector = functools.lru_cache()(_make_selector) - class _Selector: """A selector matches a specific glob pattern part against the children