Steven D'Aprano wrote: > On Tue, 05 Jun 2007 18:26:50 -0400, Terry Reedy wrote: > >> "Warren Stringer" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] | I am porting code that >> only uses this form | a[:4]b() >> | >> | Which translates to: >> | >> | for i in range(4): >> | a[i].b() >> >> Or, more directly and perhaps more efficiently: >> >> for e in a[:4]: e.b() > > I'm thinking that is more efficient only because four is a small number. > If you wanted to iterate over the first 2**22 items in a list of 2**22+1 > items, making a copy of the sub-list first would probably be a bad idea :)
Then again, in that case, so would making a list of the indices with `range`, which is what the original poster was suggesting. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis To endure what is unendurable is true endurance. -- (a Japanese proverb) -- http://mail.python.org/mailman/listinfo/python-list