mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Since instances of _TemporarilyImmutableSet are always thrown away
immediately after the comparison, there in no use in caching the hashcode. The test, 'if self._hashcode is None', never fails. Removing the caching saves a few lines and a little time.
This commit is contained in:
parent
045e51a9a5
commit
d50185127f
1 changed files with 1 additions and 5 deletions
|
@ -471,13 +471,9 @@ class _TemporarilyImmutableSet(BaseSet):
|
|||
# Wrap a mutable set as if it was temporarily immutable.
|
||||
# This only supplies hashing and equality comparisons.
|
||||
|
||||
_hashcode = None
|
||||
|
||||
def __init__(self, set):
|
||||
self._set = set
|
||||
self._data = set._data # Needed by ImmutableSet.__eq__()
|
||||
|
||||
def __hash__(self):
|
||||
if self._hashcode is None:
|
||||
self._hashcode = self._set._compute_hash()
|
||||
return self._hashcode
|
||||
return self._set._compute_hash()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue