mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
GH-104898: Revert pathlib os.PathLike registration change. (GH-105073)
Subclassing `os.PathLike` rather than using `register()` makes
initialisation slower, due to the additional `__isinstance__` work.
This partially reverts commit bd1b6228d1
.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
39f6a0489f
commit
d593074494
1 changed files with 5 additions and 1 deletions
|
@ -235,7 +235,7 @@ class _PathParents(Sequence):
|
||||||
return "<{}.parents>".format(type(self._path).__name__)
|
return "<{}.parents>".format(type(self._path).__name__)
|
||||||
|
|
||||||
|
|
||||||
class PurePath(os.PathLike):
|
class PurePath:
|
||||||
"""Base class for manipulating paths without I/O.
|
"""Base class for manipulating paths without I/O.
|
||||||
|
|
||||||
PurePath represents a filesystem path and offers operations which
|
PurePath represents a filesystem path and offers operations which
|
||||||
|
@ -715,6 +715,10 @@ class PurePath(os.PathLike):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# Subclassing os.PathLike makes isinstance() checks slower,
|
||||||
|
# which in turn makes Path construction slower. Register instead!
|
||||||
|
os.PathLike.register(PurePath)
|
||||||
|
|
||||||
|
|
||||||
class PurePosixPath(PurePath):
|
class PurePosixPath(PurePath):
|
||||||
"""PurePath subclass for non-Windows systems.
|
"""PurePath subclass for non-Windows systems.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue