[Python-checkins] python/dist/src/Objects abstract.c,2.110,2.111 classobject.c,2.164,2.165
Guido van Rossum
guido@python.org
Thu, 12 Dec 2002 13:19:17 -0500
> >
> >>To make a recursive tuple argument work, PyObject_IsSubclass()
> >>would have to call itself recursively. This would mean, that
> >>on each call redundant checks for classness would be made.
> >>
> >>I'd consider the abillity to handle recursive tuples an
> >>unfortunate side effect of the isinstance() implementation.
> >>
> >>If we want isinstance() and issubclass() to be as similar as
> >>possible, we can either deprecate recursive tuples for
> >>isinstance() or allow them for issubclass().
> >>
> >>Unfortunately recursive tuples have been documented in
> >>Doc/lib/libfuncs.tex, so we can't silently remove them.
> >>
> >>I wonder what the use case for recursive tuples is.
> >
> >
> > In Zope3, __implements__ can be a recursive tuple of (interface)
> > classes. The recursion is used e.g. as follows:
> >
> > class C:
> > __implements__ = I1, I2
> >
> > class D(C):
> > __implements__ = C.__implements__, I3, I4
> >
> > This is the same as
> >
> > __implements__ = C.__implements__ + (I3, I4)
> >
> > but much nicer. The __implements__ tuple is a good candidate for use
> > with issubclass().
>
> OK, so should I change PyObject_IsSubclass to work recursively?
Yes, please!
--Guido van Rossum (home page: http://www.python.org/~guido/)