Message257481
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. |
|
Date |
User |
Action |
Args |
2016-01-04 19:22:04 | gvanrossum | set | recipients:
+ gvanrossum, ncoghlan, r.david.murray, martin.panter, serhiy.storchaka, abarnert |
2016-01-04 19:22:04 | gvanrossum | set | messageid: <1451935324.29.0.840363611808.issue25958@psf.upfronthosting.co.za> |
2016-01-04 19:22:04 | gvanrossum | link | issue25958 messages |
2016-01-04 19:22:04 | gvanrossum | create | |
|