diff --git a/Lib/pathlib/__init__.py b/Lib/pathlib/__init__.py index a4721fbe813962..f03f317ef6c16a 100644 --- a/Lib/pathlib/__init__.py +++ b/Lib/pathlib/__init__.py @@ -169,9 +169,7 @@ def __rtruediv__(self, key): return NotImplemented def __reduce__(self): - # Using the parts tuple helps share interned path parts - # when pickling related paths. - return (self.__class__, self.parts) + return self.__class__, tuple(self._raw_paths) def __repr__(self): return "{}({!r})".format(self.__class__.__name__, self.as_posix()) diff --git a/Misc/NEWS.d/next/Library/2023-12-07-20-05-54.gh-issue-112855.ph4ehh.rst b/Misc/NEWS.d/next/Library/2023-12-07-20-05-54.gh-issue-112855.ph4ehh.rst new file mode 100644 index 00000000000000..6badc7a9dc1c94 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-12-07-20-05-54.gh-issue-112855.ph4ehh.rst @@ -0,0 +1,2 @@ +Speed up pickling of :class:`pathlib.PurePath` objects. Patch by Barney +Gale.