I’ve found some code that uses sets in Python. I tried to emulate them with lists, but I get different results when pop()ing from them!
I opened up Ipython to test how do these things work, and found something pretty strange:
In [16]: x
Out[16]: set([])
In [17]: x.add("a")
In [18]: x.add("b")
In [19]: x.add("c")
In [20]: x
Out[20]: set(['a', 'c', 'b'])
Shouldn’t 'b' come before c, because it was added before it? I don’t understand this.
http://docs.python.org/library/stdtypes.html#set
The underlying data structure of a set is a hash map, there is lots of information on those here.