Python has an ordered dictionary. What about an ordered set?
While others have pointed out that there is no built-in implementation of an insertion-order preserving set in Python (yet), I am feeling that this question is missing an answer which states what there is to be found on PyPI.
There are the packages:
Some of these implementations are based on the recipe posted by Raymond Hettinger to ActiveState which is also mentioned in other answers here.
my_set[5]
)remove(item)
Both implementations have O(1) for add(item)
and __contains__(item)
(item in my_set
).