Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Which is faster?

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


circularfunc at yahoo

Aug 29, 2008, 9:26 PM

Post #1 of 1 (35 views)
Permalink
Which is faster?

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

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.