Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Lib/pathlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,14 @@ 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
Comment thread
Zheaoli marked this conversation as resolved.
Outdated
Comment thread
Zheaoli marked this conversation as resolved.
Outdated
if self.parser is not posixpath:
hash_data = [part.lower() for part in hash_data]
self._hash = hash(tuple(hash_data))
return self._hash

def __eq__(self, other):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid useless join operation when calculate the hash vaule for pathlib.Path.
Loading