# Add \`OrderedSet\` to stdlib

**URL:** <https://discuss.python.org/t/add-orderedset-to-stdlib/12730>\
**Category:** Ideas\
**Created:** [December 24, 2021, 2:59pm UTC](https://discuss.python.org/t/add-orderedset-to-stdlib/12730 "2021-12-24T14:59:00Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![Pyprohly](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/pyprohly/32/5768_2.png) [@Pyprohly](https://discuss.python.org/u/Pyprohly)\
**Post date:** [October 22, 2022, 11:18am UTC](https://discuss.python.org/t/add-orderedset-to-stdlib/12730/8 "2022-10-22T11:18:10Z")

</div>

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.

---

_[View the full topic](https://discuss.python.org/t/add-orderedset-to-stdlib/12730)._
