Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d501851

Browse files
committed
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.
1 parent 045e51a commit d501851

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

Lib/sets.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -471,13 +471,9 @@ class _TemporarilyImmutableSet(BaseSet):
471471
# Wrap a mutable set as if it was temporarily immutable.
472472
# This only supplies hashing and equality comparisons.
473473

474-
_hashcode = None
475-
476474
def __init__(self, set):
477475
self._set = set
478476
self._data = set._data # Needed by ImmutableSet.__eq__()
479477

480478
def __hash__(self):
481-
if self._hashcode is None:
482-
self._hashcode = self._set._compute_hash()
483-
return self._hashcode
479+
return self._set._compute_hash()

0 commit comments

Comments
 (0)