how to remove 50000 elements from a 100000 list?

Peter Otten __peter__ at web.de
Fri May 5 12:15:59 EDT 2006


Ju Hui wrote:

> cool!
> thanks you all!
> I choose
> a=set(range(100000))
> b=set(range(50000))
> a.symmetric_difference(b)
> certainly,the real data not range(), I am satisfied the performance of
> set.difference
> 
> thank you all again!

Be warned that this may /add/ items to a:

>>> set("abc").symmetric_difference("bcd")
set(['a', 'd'])

If your subject is correct you want difference(), not
symmetric_difference().

Peter



More information about the Python-list mailing list