# new new 2 years = set() for variant in self.model_variants: years.add(variant.intro_date) years.add(variant.end_date) years = sorted(years) # new new new years = sorted(set((variant.intro_date, variant.end_date) for variant in self.model_variants)) # new new years = set() for variant in self.model_variants: years.add((variant.intro_date, variant.end_date)) years = sorted(years) #new years = set() for dates in [(variant.intro_date, variant.end_date) for variant in self.model_variants]: years = years.union(dates) years = sorted(years) # old years = sorted(reduce(set.union, [(variant.intro_date, variant.end_date) for variant in self.model_variants], set()))