From: Barney Gale Date: Sun, 10 Dec 2023 00:06:27 +0000 (+0000) Subject: GH-112906: Fix performance regression in pathlib path initialisation (#112907) X-Git-Tag: v3.13.0a3~455 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=23df46a1dde82bc5a51578d9443024cf85827b95;p=thirdparty%2FPython%2Fcpython.git GH-112906: Fix performance regression in pathlib path initialisation (#112907) This was caused by 76929fdeeb, specifically its use of `super()` and its packing/unpacking `*args`. Co-authored-by: Alex Waygood --- diff --git a/Lib/pathlib/__init__.py b/Lib/pathlib/__init__.py index f4668ab3270e..b020d2db350d 100644 --- a/Lib/pathlib/__init__.py +++ b/Lib/pathlib/__init__.py @@ -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