<p dir="ltr"><br>
On Nov 8, 2015 1:46 PM, "Guido van Rossum" <<a href="mailto:guido@python.org">guido@python.org</a>> wrote:<br>
><br>
> I'm warming up slightly to the idea of this ABC.<br>
><br>
> I've re-read Amir's post, and if I found myself in his situation I would have used a combination of documenting that __slots__ needs to be ordered and at runtime only checking for a few common definitely-bad cases. E.g. for exactly set or dict (not subclasses, since OrderedDict inherits from dict) would cover most of the common mistakes: most people will use a literal in their __slots__ definition so we just need to watch out for the common literals. Those users who are sophisticated enough to use some advanced mapping type in their __slots__ should just be expected to deal with the consequences.<br>
><br>
> But the Ordered ABC, while not essential (unless you're a perfectionist, in which case you're in the wrong language community anyways :-) still fills a niche.</p>
<p dir="ltr">I take issue with this comment because it's in the middle of the text.</p>
<p dir="ltr">It's more than a perfection thing:</p>
<p dir="ltr">- Ordered collections may already be Sorted [1]</p>
<p dir="ltr">- [ ] would collectiond.namedtuple [~struct w/ slots] also be Ordered</p>
<p dir="ltr">- [1] here's a rejected PR for jupyter/nbformat <a href="https://github.com/jupyter/nbformat/pull/30">https://github.com/jupyter/nbformat/pull/30</a> "ENH: v4/nbjson.py: json.loads(object_pairs_hook=collections.OrderedDict)"<br><br><br></p>
<p dir="ltr">><br>
> The Ordered ABC should have no additional methods, and no default implementations. I think it should apply to collections but not to iterators. It should apply at the level of the read-only interface. Sequence is always Ordered. Mapping and Set are not by default, but can have it added. OrderedDict is the prime (maybe only) example -- it's a MutableMapping and Ordered. We might eventually get an OrderedSet.<br>
><br>
> A sorted set or mapping (e.g. one implemented using some kind of tree) should also be considered Ordered, even though otherwise this is a totally different topic -- while some other languages or branches of math use "order" to refer to sorting (e.g. "partial ordering"), in Python we make a distinction: on the one hand there's sorted() and list.sort(), and on the other hand there's OrderedDict.<br>
><br>
> So, I think that the Ordered ABC proposed here is totally well-defined and mildly useful. It may be somewhat confusing (because many people when they first encounter the term "ordered" they think it's about sorting -- witness some posts in this thread). The use cases are not very important. I guess I'm -0 on adding it -- if better use cases than Amir's are developed I might change to +0. (I don't care much about Serhiy's use cases.)<br>
><br>
> Sorry for the rambling.<br>
><br>
> -- <br>
> --Guido van Rossum (<a href="http://python.org/~guido">python.org/~guido</a>)<br>
><br>
> _______________________________________________<br>
> Python-ideas mailing list<br>
> <a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/python-ideas">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
> Code of Conduct: <a href="http://python.org/psf/codeofconduct/">http://python.org/psf/codeofconduct/</a><br>
</p>