Use kits or freezats.
set_a = {1, 2, 3, 4} #python 2.7 or higher set literal, use the set(iter) syntax for older versions set_b = {2, 4, 4, 1} set_a == set_b set_a - set_b == set_b - set_a
The biggest advantage of using sets over any list method is that it is very readable, you have not changed your original iterative image, it can work well even when it is huge, and b is tiny (checking if there is a and b is the same length at first is a good optimization if you expect this to happen often), and using the correct data structure for the job is pythonic.
marr75
source share