def __str__(self):
    """Convert the revision set to a string, using its normalized form."""
L = []
for s, e in self.normalized():
    if s == e:
        L.append(str(s))
else:
    L.append(str(s) + '-' + str(e))
return ','.join(L)
How to optimize operations on large (75,000 items) sets of booleans in Python?