There was a somewhat ancient discussion on OrderedDict and OrderedSet before: <a href="http://mail.python.org/pipermail/python-dev/2005-March/051915.html">http://mail.python.org/pipermail/python-dev/2005-March/051915.html</a><br>
<br>The resolution seemed to be that neither of them should be in stdlib. Now that OrderedDict is in and Raymond Hettinger has created a solid OrderedSet implementation: <a href="http://code.activestate.com/recipes/576694/">http://code.activestate.com/recipes/576694/</a> , could the latter also be included in collections?<br>
<br>Here's a very generic use-case:<br><br>def _update_key(dct, key, val):<br> """<br> Update a key in dict *dct*. If they key already exists in *dct* but the<br> value doesn't, a set of previous values is created and the value added to it.<br>
"""<br> if key in dct:<br> if dct[key] == val:<br> return<br> s = set(dct[key])<br> s.update(val)<br> dct[key] = s<br> else:<br> dct[key] = val<br><br>
The problem is that I both need to remove duplicates and retain insertion order like list.append().<br>