how to remove 50000 elements from a 100000 list?

Larry Bates larry.bates at websafe.com
Fri May 5 16:22:39 EDT 2006


Peter Otten wrote:
> 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

Whoops.  My bad.  Peter is correct.

-Larry



More information about the Python-list mailing list