Thanks for the comment. Yes, I was strictly saying “there are clearly use case for ordered sets” in response to the other poster. I agree that including them in standard library needs to be justified. That’s what we’re trying to work on in this thread.
I’ll start off by re-iterating that I haven’t contributed to Python before, so I don’t know that the cultural norm/bar is for including something in the standard library and what sorts of considerations are typically made. I think there’s evidence here that there would be some good benefits. I don’t see any downsides to including it other than the effort that has to be put in. If anyone has downsides other than the effort to include it I’d really want to hear those points.
My main argument for why OrderedSet is a good candidate to include compared to those other libraries is that OrderedSet feels very qualitatively similar in many ways to OrderedDict which has been included for a long time, and at least to someone who finds themselves having a need for an ordered set, and who has a cost associated with including external dependencies, the lack of OrderedSet
next to OrderedDict
feels like a hole/oversight in the collections
library.
To address your specific questions: I haven’t done deep research into the different options yet. I’m relying mostly on this Stack Overflow question and answer: Does Python have an ordered set? - Stack Overflow. The main options I see:
- “orderedset” cython pacage feels like a good option since it is probably most performant.
- The pure python “ordered-set” package would probably be good.
- I haven’t looked into the implementation in
collections-extended
. - Reverting to having
OrderedSet
derive fromdict
orOrderedDict
as sets used to in older versions of python.
I can reach out to the maintainers of the first 3 to see if they have any interest in having their implementation included in the standard library.
I don’t know who will write the code. I’m open to helping with that effort but would have to learn a lot. I don’t know who typically writes code like this, I guess folks here.
The code would be maintained by the same person/people who are currently maintain the collections
package. I could reach out to them as well (hints as to the best avenue to do this would be appreciated, I assumed this discussion forum would get me close…) to get their input.
Again, whatever the justification was for including OrderedDict
in collections
, or making regular dicts ordered, could probably be copy and pasted to justify the inclusion of OrderedSet
.