Message 81222 - Python tracker (original) (raw)

Even more inconveniently, the existence of unregister() on ABCs makes it difficult for the generic to cache the results of the isinstance() checks (you don't want to be going through the chain of registered ABCs every time calling isinstance(), since that would be painfully slow).

That said, it is already the case that if you only register with an ABC, you don't get any of the methods - you have to implement them yourself. It's only when you actually inherit from the ABC that the methods are provided "for free". I guess the case isn't really any different here - if you changed your example so that A inherited from C and D rather than merely registering with them, then C & D would appear in the MRO and the generic would recognise them.

So perhaps just documenting the limitation is the right answer after all.