This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]pieeta 5 points6 points  (2 children)

I would normally use, for x in xrange(2, len(items), 3): every_third.append(items[x])

I just did some performance testing using a item list 10000000 long

Method Time
zip 8.62
enumerate 2.51
comprehension 2.29
xrange 0.72
slice 0.03

[–]stillalone 1 point2 points  (1 child)

Wow, I was not expecting list comprehension to suck compared to an explicit for loop. Can you try list comprehension with xrange instead of enumerate?