pairs from a list

Paul Rubin http
Mon Jan 21 22:47:43 EST 2008


Alan Isaac <aisaac at american.edu> writes:
> (Of course the print statement is just illustrative.)
> What is the fastest way? (Ignore the import time.)

You have to try a bunch of different ways and time them.  One
idea (untested):

    def pairs(seq):
       while True:
           yield (seq.next(), seq.next())



More information about the Python-list mailing list