From d50185127f5cdc7241e5aa80d4d174113bf43b52 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sat, 24 Aug 2002 04:47:42 +0000 Subject: [PATCH] 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. --- Lib/sets.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Lib/sets.py b/Lib/sets.py index 19dbbaa371..5ca85deab7 100644 --- a/Lib/sets.py +++ b/Lib/sets.py @@ -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() -- 2.40.0