[Python-Dev] inheriting basic types more efficiently
"Martin v. Löwis"
martin at v.loewis.de
Thu Apr 27 21:46:18 CEST 2006
Dennis Heuer wrote:
> The real misunderstanding lies somewhere else. I thought that the
> bitarray's instance would have more control over the long type's
> instance, like with the mutable types. I thought that the long type's
> superclass would provide methods similar to __setitem__ that would
> allow the bitarray instance to even *refresh* (or substitute) the long
> instance in place. The result would be a freshly created long instance
> substituting the old one. But the immuntable types do not offer such a
> feature because one cannot substitute the long instance without
> breaking the bitarray instance too.
Maybe that's the misunderstanding: but then you are still left with
the mis-design. Even if long was mutable, or even if you used a mutable
type as the base type (such as array.array), you *still* shouldn't
inherit from it - these types are not in an "is-a" relationship.
More information about the Python-Dev