89 .all()
90 )
91 data = dict(stats)
92 data['total'] = sum([x for _, x in stats]) 93
94 return data
95
48 .all()
49 )
50 data = dict(stats)
51 data['all'] = sum([x for _, x in stats]) 52
53 return data
54
Using a container in place of a generator for a calls that can accept both, slows down the performance. Consider using generators for all function calls which accept both containers and genertors.
# List comprehension is unnecessary here
set([student.name for student in student])
sum([y**2 for y in list(range(10))])
set(student.name for student in students)
sum(y**2 for y in list(range(10)))