[Python-Dev] Py2.6 buildouts to the set API (original) (raw)
"Martin v. Löwis" martin at v.loewis.de
Sat May 19 09:19:36 CEST 2007
- Previous message: [Python-Dev] Py2.6 buildouts to the set API
- Next message: [Python-Dev] Py2.6 buildouts to the set API
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
* New method (proposed by Shane Holloway): s1.isdisjoint(s2). Logically equivalent to "not s1.intersection(s2)" but has an early-out if a common member is found. The speed-up is potentially large given two big sets that may largely overlap or may not intersect at all. There is also a memory savings since a new set does not have to be formed and then thrown away.
I'd rather see iterator versions of the set operations. Then you could do
def isempty(i): try: i.next() except StopIteration: return True else: return False
if isempty(s1.iter_intersection(s2)): ...
* Additional optional arguments for basic set operations to allow chained operations. For example, s=s1.union(s2, s3, s4) would be logically equivalent to s=s1.union(s2).union(s3).union(s4) but would run faster because no intermediate sets are created, copied, and discarded. It would run as if written: s=s1.copy(); s.update(s2); s.update(s3); s.update(s4).
I'd rather see this as collections.bigunion.
* Make sets listenable for changes (proposed by Jason Wells):
-1, IAGNI.
Martin
- Previous message: [Python-Dev] Py2.6 buildouts to the set API
- Next message: [Python-Dev] Py2.6 buildouts to the set API
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]