fast sub list operations

Robin Becker robin at jessikat.fsnet.co.uk
Tue Oct 16 07:33:58 EDT 2001


I constantly miss some nice way to subset lists. As an example suppose I
have a list of x y coordinates eg

        [x0,y0,x1,y1,.....]

and wish to perform the operation x->x+v, y->y+w for the co-ordinates in
the list I don't seem to be able to do this fast using map. Even if I
had a way to slice the list nicely into

X=[x0,x1,.....x(n-1)] & Y=[y0,y1,.....,y(n-1)]

so that I can do map(operator.add,X,n*[v]) to perform the arithmetic
quickly I don't seem to have an interlace to get back to the original
list format.

How can these kinds of operations be performed quickly in current python
and what if any new features would python require to do them best?
-- 
Robin Becker



More information about the Python-list mailing list