Re: [Python-ideas] Adding collections.abc.Ordered

On Dec 26, 2015 8:11 PM, "Wes Turner" <wes.turner@gmail.com> wrote:
about [complexity, types, runtime]?
[While someone is at it, annotating functions and methods with complexity
class URI fragments accessible at runtime could also be useful for [dynamic programming].]
(because then you don't have to do element-wise comparisons for each collection member)
...
* collections.abc.Recursive could also be a useful property to mixin
[again for dynamic programming]
https://en.wikipedia.org/wiki/Goal_programming There are more properties of sequences listed here; IDK if this is out of scope for OT: https://en.wikipedia.org/wiki/Sequence#Formal_definition_and_basic_propertie... Vague use case: algorithmic selection / unhalting-avoidance with combinatorial data/logic sequences. [e.g. find the fastest halting solution] Practically, Ordered is a property of various types [e.g. is this a poset or not]. There is currently no way to check for .ordered with hasattr. These properties are things we currently keep in mind (some of our 7±2 things) and haven't yet figured out how to annotate with and access at runtime.
python-ideas@python.org> wrote:
collections.abc.Ordered. >>> >>> > May be we have to use this idiom more widely, and specially handle assigning special methods to None. The error message "'sometype' can't be reverted" looks better than "'NoneType' is not callable". >>> >>> I agree with this. A new collections.abc.Reversible (interposed between Iterable and Sequence) would be a potential substitute for Ordered, and would have this problem, which would be solvable by treating __reversed__ = None specially, just like __hash__ = None. And I'm pretty sure it would come up in practice (see issue 25864). And once we've got two or three special methods doing this instead of one, making it more general does sound like a good idea. So, if we need Reversible as a substitute for Ordered, then I think we want the general "is None" test. >>> >>> But I'm still not sure Reversible is a good substitute for Ordered (again, consider an infinitely long collection, or just a lazy proxy that doesn't compute values until needed and doesn't know its length in advance--they're clearly ordered, and just as clearly not reversible), and I'm not sure we actually need either Reversible or Ordered in the first place. >>> >>> _______________________________________________ >>> Python-ideas mailing list >>> Python-ideas@python.org >>> https://mail.python.org/mailman/listinfo/python-ideas >>> Code of Conduct: http://python.org/psf/codeofconduct/
participants (1)
-
Wes Turner