On Fri, 2007-10-05 at 07:27 -0700, Abandoned wrote: > Hi.. > I have a problem.. > list1=[11, 223, 334, 4223...] 1 million element > list2=[22,223,4223,2355...] 500.000 element > > I want to difference list1 to list2 but order very importent.. > > My result must be: > list3=[11,334,...] > > I do this use FOR easly but the speed very imported for me. I want to > the fastest method please help me.
If you can write this as a for/append loop, then you can easily rewrite it into a list comprehension: <blank1> = [] for <blank2> in <blank3>: if <blank4>: <blank1>.append(<blank2>) becomes <blank1> = [<blank2> for <blank2> in <blank3> if <blank4>] Now all you need to do is fill in the blanks. As a hint for what exactly to fill in for blank4, remember (or be advised) that Python has sets. HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list