Guido van Rossum added the comment:

I propose to solve the narrow problem by indeed supporting the setting of 
certain special methods to None similar to __hash__. This should be limited to 
those methods for which this adds value, e.g. where the complete absence of the 
method causes a fall-back to a different API (e.g. __getitem__+__len__ in the 
case of __reversed__) -- the None value should just block the fallback. This 
will require some changes in the ABCs that test for the presence of a given 
method (Iterable/__iter__, Container/__contains__, Reversible/__reversed__ -- 
the latter ABC should be added) and in implementations such as reversed(), 
iter() and 'in'. Maybe we should just do this for every ABC in collections.abc 
(plus Reversible) that has a __subclasshook__ that tests for the presence of 
the special method.

Oh, probably some more, like Iterator/__next__, Sized/__len__ and 
Callable/__call__. But for those there isn't a fallback in the corresponding 
bytecode, so I'm only +0 for those -- it doesn't seem to harm anything to be 
consistent with those for which it does matter, but it doesn't cost much 
either, and the consistency is slightly useful -- it provides a pattern to 
follow for future ABCs.

----------
nosy: +gvanrossum

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25958>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to