"Dinesh B Vadhia" <[email protected]> wrote

As the lists of integers get larger ... the list comprehension solution will get slower. Do you agree?

Yes thats why Chris said the linear loop solution is almost certainly faster in this case. However you could speed up the for loop significantly by missing out the call to enumerate():

for x in d:
       y += x
       dd.append(y)

Should give the same result...

List Comprehensions are not always the best answer.


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to