Splitting lists
Terry Reedy
tjreedy at udel.edu
Thu Feb 27 17:16:21 EST 2003
More information about the Python-list mailing list
Thu Feb 27 17:16:21 EST 2003
- Previous message (by thread): Splitting lists
- Next message (by thread): Splitting lists
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Létezõ" <letezo at fw.hu> wrote in message news:mailman.1046363056.19603.python-list at python.org... > Dear List Splitters! > > Thanks to Steven for the performance analysis and Alex & Duncan for the > their more impressive solutions. It would be interesting to insert the new > "impressive" solutions into the performace test loop. Which is the fastest? > > Proposed solutions in reverse time order: Here is another 'symmetrical' version tl,fl = [],[] ta,fa = tl.append, fl.append for i in range(-5,5): ((i >=0) or fa(i)) and ta(i) fl,tl #([-5, -4, -3, -2, -1], [0, 1, 2, 3, 4]) but unless it surprised me by being faster, I also prefer > # Duncan: (my current favourite) > fl=[] > tl = [ x for x in test if fn(x) or fl.append(x) ] with fl.append factored out Terry J. Reedy
- Previous message (by thread): Splitting lists
- Next message (by thread): Splitting lists
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list