mirror of
https://github.com/python/cpython.git
synced 2026-02-06 18:01:17 +00:00
gh-138407: avoid useless join operation when calculate the hash vaule for pathlib.Path
Signed-off-by: Manjusaka <me@manjusaka.me>
This commit is contained in:
parent
097c563e7b
commit
e1a76da0a1
1 changed files with 6 additions and 1 deletions
|
|
@ -209,7 +209,12 @@ def __hash__(self):
|
|||
try:
|
||||
return self._hash
|
||||
except AttributeError:
|
||||
self._hash = hash(self._str_normcase)
|
||||
hash_data = self._tail
|
||||
if self._drv or self._root:
|
||||
hash_data = [self._drv + self._root] + self._tail
|
||||
elif self._tail and self.parser.splitdrive(self._tail[0])[0]:
|
||||
hash_data = ['.'] + self._tail
|
||||
self._hash = hash(tuple(hash_data))
|
||||
return self._hash
|
||||
|
||||
def __eq__(self, other):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue