flatten a level one list

Robin Becker robin at SPAMREMOVEjessikat.fsnet.co.uk
Thu Jan 12 02:18:20 CET 2006


Is there some smart/fast way to flatten a level one list using the 
latest iterator/generator idioms.

The problem arises in coneverting lists of (x,y) coordinates into a 
single list of coordinates eg

f([(x0,y0),(x1,y1),....]) --> [x0,y0,x1,y1,....] or

g([x0,x1,x2,......],[y0,y1,y2,....]) -->  [x0,y0,x1,y1,....]

clearly if f is doable then g can be done using zip. I suppose this is a 
special case flatten, but can flatten be done fast? The python  recipes 
seem rather slow compared to the builtin functions.
-- 
Robin Becker



More information about the Python-list mailing list