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 :) Is there a general Pythonic idiom for efficiently walking over part of a sequence without copying it first? Should there be? -- Steven. -- http://mail.python.org/mailman/listinfo/python-list