[PEAK] Type and class adaptation
Phillip J. Eby
pje at telecommunity.com
Mon Nov 22 20:42:28 EST 2004
At 09:38 AM 11/22/04 +0100, Radek Kanovsky wrote:
>On Fri, Nov 19, 2004 at 02:15:30PM -0500, Phillip J. Eby wrote:
> > if None in table:
> > return table[None]
>Isn't 'None' key in the table everytime if it is returned by seeds() method?
>Is the last 'if None in table' necessary?
No, I suppose not, as long as anything that uses that dispatch function
always has None as a seed. So I guess you're right.
>It is more clear to me now. Docstring for seeds() says that this method
>should "Return iterable of known-good keys". From the existing code
>in dispatching package I have got the picture that "good keys" are
>extreme values in some sense (MIN/MAX for comparables, 'object' for
>class/types hierarchy) plus important value itself.
Something like that, yes. It's basically, "all the borderline values". Or
really, it should be "all possible values, less any that you can prove you
won't need". For example, we don't need classes for which nothing has been
declared and which have only a single base class.
> Nothing can be
>subclass of 'None' so it hasn't seemed to be a good key :) On the other
>hand, there are some classes that hasn't 'object' among their bases. So
>I suppose that None has role of some marker or sentinel here - "bad key"
Yeah, it's really more like "all possible values, less redundant
ones". The docstring for seeds() is really old, maybe even from before I
added range testing.
>------------------------ implementation ---------------------------
May I include the implementation in PEAK/PyProtocols?
More information about the PEAK