]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-112906: Fix performance regression in pathlib path initialisation (#112907)
authorBarney Gale <barney.gale@gmail.com>
Sun, 10 Dec 2023 00:06:27 +0000 (00:06 +0000)
committerGitHub <noreply@github.com>
Sun, 10 Dec 2023 00:06:27 +0000 (00:06 +0000)
This was caused by 76929fdeeb, specifically its use of `super()` and its
packing/unpacking `*args`.

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Lib/pathlib/__init__.py

index f4668ab3270e51dc5974416b0482aff8273e01cf..b020d2db350da86420ec944376fe7d8614eb01a6 100644 (file)
@@ -90,7 +90,9 @@ class PurePath(_abc.PurePathBase):
                         "object where __fspath__ returns a str, "
                         f"not {type(path).__name__!r}")
                 paths.append(path)
-        super().__init__(*paths)
+        # Avoid calling super().__init__, as an optimisation
+        self._raw_paths = paths
+        self._resolving = False
 
     def __reduce__(self):
         # Using the parts tuple helps share interned path parts