]> granicus.if.org Git - python/commitdiff
Since instances of _TemporarilyImmutableSet are always thrown away
authorRaymond Hettinger <python@rcn.com>
Sat, 24 Aug 2002 04:47:42 +0000 (04:47 +0000)
committerRaymond Hettinger <python@rcn.com>
Sat, 24 Aug 2002 04:47:42 +0000 (04:47 +0000)
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

index 19dbbaa37116e8133bf2742c735e80f6f7da4715..5ca85deab7ae1067271cc889eea21f23333ac6fc 100644 (file)
@@ -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()