diff options
author | Tim Peters <tim.peters@gmail.com> | 2002-08-25 19:47:54 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2002-08-25 19:47:54 (GMT) |
commit | 334b4a5c393fba0b3cf37ed88b36cbd554a24f4f (patch) | |
tree | 3043d23234d8d388fca19cd57919b9a1565f1903 | |
parent | 37faed2532b3baf3b24cd4839aa5f5242b0c807d (diff) | |
download | cpython-334b4a5c393fba0b3cf37ed88b36cbd554a24f4f.zip cpython-334b4a5c393fba0b3cf37ed88b36cbd554a24f4f.tar.gz cpython-334b4a5c393fba0b3cf37ed88b36cbd554a24f4f.tar.bz2 |
Gave __xor__/symmetric_difference a factor of 2-5 speed boost.
-rw-r--r-- | Lib/sets.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/sets.py b/Lib/sets.py index 10138fc..bf3ff4d 100644 --- a/Lib/sets.py +++ b/Lib/sets.py @@ -197,11 +197,13 @@ class BaseSet(object): result = self.__class__() data = result._data value = True - for elt in self: - if elt not in other: + selfdata = self._data + otherdata = other._data + for elt in selfdata: + if elt not in otherdata: data[elt] = value - for elt in other: - if elt not in self: + for elt in otherdata: + if elt not in selfdata: data[elt] = value return result |