From 23df46a1dde82bc5a51578d9443024cf85827b95 Mon Sep 17 00:00:00 2001 From: Barney Gale Date: Sun, 10 Dec 2023 00:06:27 +0000 Subject: 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 --- Lib/pathlib/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/pathlib/__init__.py b/Lib/pathlib/__init__.py index f4668ab..b020d2d 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 -- cgit v0.12