
circularfunc at yahoo
Aug 29, 2008, 9:26 PM
Post #1 of 1
(35 views)
Permalink
|
For a big nbr of it might matter? Is av_grade O(n*2) and the first O(n) when it comes to adding or is "sum x for x in y" just traversing the list ones, accumulating the values, it doesnt first build the list and then travese it for sum? def averageGrade(self): tot = 0 for review in self.reviews: tot += review.grade return tot / len(self.reviews) def av_grade(self): return sum(review.grade for review in self.reviews) / \ len(self.reviews) -- http://mail.python.org/mailman/listinfo/python-list
|