[Python-3000] PEP 3133: Introducing Roles

Steven Bethard steven.bethard at gmail.com
Mon May 14 22:33:31 CEST 2007


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".

STeVe
-- 
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
        --- Bucky Katt, Get Fuzzy


More information about the Python-3000 mailing list