Why are so many built-in types inheritable?

Antoon Pardon apardon at forel.vub.ac.be
Fri Mar 31 10:41:48 CEST 2006


Op 2006-03-31, Georg Brandl schreef <g.brandl-nospam at gmx.net>:
> 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?

That depends.

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

Well that looks somewhat short sighted to me. It is also why python
seems to throws so many surprises at people.

My impression is that quite frequently people come here with a question
about why something doesn't work, that normally could be expected to
work.

The reason why it doesn't work then seems to boil down to the
developpers not taking the trouble of implementing something
in general but only for the cases for which they could imagine
a use case. Which means that when someone comes up with a use
case later he is stuck.

I know about practicality beating purity, but purity has it
practical aspects too. If the python people had been willing
to work a bit more at purity, that would have been a lot
of more practical for those who found something not working
as expected, although they had no reason to suspect so.

-- 
Antoon Pardon



More information about the Python-list mailing list