[Python-3000] PEP 3133: Introducing Roles

Collin Winter collinw at gmail.com
Wed May 16 00:30:13 CEST 2007


On 5/14/07, Steven Bethard <steven.bethard at gmail.com> wrote:
> On 5/14/07, Collin Winter <collinw at gmail.com> wrote:
> > There really is no difference between roles and all- at abstractmethod
> > ABCs. From my point of view, though, roles win because they don't
> > require any changes to the interpreter; they're a much simpler way of
> > expressing the same concept.
>
> Ok, you clearly have an implementation in mind, but I don't know what
> it is.  As far as I can tell:
>
> * metaclass=Role ~ metaclass=ABCMeta, except that all methods must be abstract
> * perform_role(role)(cls) ~ role.register(cls)
> * performs(obj, role) ~ isinstance(obj, role)
>
> And so, as far as I can see, without an Implementation section, all
> you're propsing is a different syntax for the same functionality. Was
> there a discussion of your implementation that I missed?
>
> > You may like adding the extra complexity
> > and indirection to the VM necessary to support
> > issubclass()/isinstance() overriding, but I don't.
>
> Have you looked at Guido's issubclass()/isinstance() patch
> (http://bugs.python.org/1708353)?  I'd hardly say that 34 lines of C
> code is substantial "extra complexity".

This is what I don't understand: ABCs require changing the VM, roles
don't; all that change buys you is the ability to spell "performs()"
as "isinstance()". Why are ABCs preferable, again?

Collin Winter


More information about the Python-3000 mailing list