[Python-Dev] ABCs and MRO

Terry Reedy tjreedy at udel.edu
Mon Mar 2 17:28:41 CET 2009


Paul Moore wrote:
> 2009/3/2 Benjamin Peterson <benjamin at python.org>:
>> 2009/3/1 Paul Moore <p.f.moore at gmail.com>:
>>> Is it worth getting simplegeneric exposed in 3.1
>>> (http://bugs.python.org/issue5135)? If it's going to be in 2.7, I'd
>>> like to see it hit 3.1. The patch is against trunk (for 2.7) at the
>>> moment, I'm not sure what the process would be for forward-porting it
>>> (do I generate a new patch against the py3k branch, or should it be
>>> applied to trunk and merged in?)
>> Patches to the trunk are fine.
> 
> OK, thanks.
> 
>> As for the actual feature, I don't think it should hold up releases.
> 
> Fair enough.

Given that the purpose of 2.7 is
a) maintenance of existing code (which can include minor new features 
for existing facilities), and
b) easing conversion of code to 3.1
I am puzzled at the idea of adding a new facility to 2.7 that would not 
be in 3.1+.  It would lock code into 2.7+ and counter purpose b).

> The key problem with the patch is that ABCs do not play well with the
> type of introspection required to implement a generic function -
> namely enumeration of the superclasses of a class. The MRO of the
> class is fine for normal inheritance, but for ABCs it is possible to
> register classes which don't inherit from the ABC, so that you have a
> situation where issubclass (C, MyABC) can be true without MyABC being
> in C.__mro__:

I have no idea of what the solution should be other than your proposed 
'document the limitations', but someone who has moved on to 3.x and is 
only interested in generics would find it frustrating to be denied them 
because of the existence of something else they are not using.

Terry Jan Reedy





More information about the Python-Dev mailing list