On Mon, Mar 2, 2009 at 1:14 PM, Paul Moore <p.f.mo...@gmail.com> wrote:
> 2009/3/2 Jeffrey Yasskin <jyass...@gmail.com>:
>> I tend to think it's a bug in ABCs. You seem to have thought of
>> several possible ways to fix it, and I don't have strong preferences
>> between them.
>
> I've discussed ways of fixing simplegeneric, but not of fixing the
> issue with ABCs. I'm not sure the ABC "issue" is fixable - after all,
> it's by design that ABCs can implement __issubclass__ and "magically"
> become superclasses of arbitrary classes as a result.
>
> I'm not happy about fixing simplegeneric, though, as the whole point
> was just to expose an existing implementation, because it might be
> generally useful. If we start expanding and enhancing it, there are
> better implementations already available on PyPI (better in the sense
> of having seen real-world use). And if they don't handle ABCs, then
> that might indicate that needing to handle ABCs isn't as vital as this
> discussion would seem to imply (but I have no real-world data myself
> to make such a claim).
>
>> One way to deal with __subclasscheck__ definitions other than
>> ABCMeta.__subclasscheck__ would be to make the "someone registered a
>> subclass" interface public in addition to the "tell me when someone
>> registers a subclass" interface. Then other __subclasscheck__
>> definitions could call the "someone registered a subclass" method when
>> the class is defined if they want to be usable with generic functions.
>
> I'm not sure I follow this. Can you clarify? My intuition is that *no*
> notification hook can deal with ABCs that code arbitrary checks in
> their __subclasscheck__ method (so there's no registration involved,
> particular classes just "magically" become subclasses).

Hm, oops, you're right. So you'd have to scan the relevant abcs and
cache the list that turns up true ... probably with cooperation from
the ABCs so you'd know when to invalidate the cache. Ick.
Unfortunately, I think overloading functions on Number or Iterable
would be really useful, and constraining it to only look at base
classes would be unfortunate.

>> You can get something similar to the mro by checking whether ABCs are
>> subclasses of each other.
>
> The key point about the MRO is that you get it just from the initial
> class, via __mro__. You're not checking if another class is *in* the
> MRO, but rather you're *generating* the list of classes in the MRO.

I was trying to reply to PJE's statement that "The hairier issue for
these types of systems is method precedence". I agree that getting the
set of abcs for an instance is more difficult that I'd thought.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to