Why are so many built-in types inheritable?

Georg Brandl g.brandl-nospam at gmx.net
Fri Mar 31 02:51:23 EST 2006


Antoon Pardon wrote:
> Op 2006-03-30, Michele Simionato schreef <michele.simionato at gmail.com>:
>> I cannot find the reference now, but I remember Tim Peters saying some
>> time ago that the only
>> reason why FunctionType is not subclassable is that nobody bothered to
>> write a patch for it.
> 
> The question then is, why is there a need for such a patch?
> 
> I mean when types and classes became unified and ints, lists ... became
> subclassable one would think that in all those new code that had to be
> written, it wouldn't have been that difficult to see to it that all
> types became subclassable. I find it hard to believe that in the
> unification period the decision to make one type subclassable and
> an other not was made solely on the basis that a patch was submitted
> for the first but not for the other.

It's not that hard to understand, is it? Whoever made the builtin types new-
style types didn't add the BASETYPE flag to function or slice. Apparently
he thought it wasn't worth the effort as he couldn't imagine a use case for it.

So, when someone had liked them to be subclassable, he'd have written a patch.

Georg



More information about the Python-list mailing list