I still wish for OrderedSet
.
I like to use an ordered set as the backing collection type when implementing the observer pattern. A regular set might be adequate for this, but I have the impression that most users would want predictable firing orders for handlers. If it were included in the standard library, it would have been a good candidate as the backing collection type for Future.add_done_callback()
, and Future.remove_done_callback()
would be O(1). Admittedly, a lot of observer pattern implementations, such as C#’s event
keyword, just use an array/list.
Another use case I had for this collection type is for monitoring changes in some external listing. Fast membership testing is beneficial here. But for this scenario, I need something like a BoundedSet
which is an OrderedSet
with a maximum size, similar to what collections.deque
has.