diff options
author | Raymond Hettinger <python@rcn.com> | 2002-08-24 04:47:42 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2002-08-24 04:47:42 (GMT) |
commit | d50185127f5cdc7241e5aa80d4d174113bf43b52 (patch) | |
tree | 824e150dc64f9fe7a4f6caa2fd7fc3b4980c7438 /Lib/sets.py | |
parent | 045e51a9a557c829d184257b32d594e7b3c9ba8a (diff) | |
download | cpython-d50185127f5cdc7241e5aa80d4d174113bf43b52.zip cpython-d50185127f5cdc7241e5aa80d4d174113bf43b52.tar.gz cpython-d50185127f5cdc7241e5aa80d4d174113bf43b52.tar.bz2 |
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.
Diffstat (limited to 'Lib/sets.py')
-rw-r--r-- | Lib/sets.py | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/Lib/sets.py b/Lib/sets.py index 19dbbaa..5ca85de 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() |