performance improvement: only create new relation if necessary, simplified

This commit is contained in:
Helmut Merz 2011-11-21 12:35:07 +01:00
parent c6638e7b5e
commit 02e07c0e85

View file

@ -482,13 +482,14 @@ class ParentRelation(object):
return None return None
def __set__(self, inst, value): def __set__(self, inst, value):
s = ParentRelationSet(inst, self.predicateName) rs = ParentRelationSet(inst, self.predicateName)
for current in s: rsList = list(rs)
for current in rsList:
if current != value: if current != value:
s.remove(current) rs.remove(current)
if value is not None: if value is not None:
if value not in s: if value not in rsList:
s.add(value) # how to supply additional parameters? rs.add(value) # how to supply additional parameters?
# caching (TBD) # caching (TBD)