[Numpy-discussion] Trouble subclassing ndarray
njs at pobox.com
Fri Apr 10 01:05:32 EDT 2015
On Fri, Apr 10, 2015 at 12:30 AM, Elliot <permafacture at gmail.com> wrote:
> I'm trying to create an object with multiple inheritance, one of which is
> from numpy.ndarray.
Sorry that this is an unhelpful answer, but I want to quickly say that
this sentence sets off all kinds of alarm bells in my mind.
Subclassing ndarray is almost always a bad idea (really it is always a
bad idea, just sometimes you have absolutely no alternative), and
multiple inheritance is almost always a bad idea (well, personally I
think it actually always is a bad idea, but I recognize that opinions
differ), and I am 99.999% sure that any design that can be described
by the sentence quoted above is a design that you will look back on
and regret. Sorry to be the bearer of bad news. Maybe you can just
have a simple object that implements the cacheable behaviour and also
has an ndarray as an attribute (i.e., your object could HAS-A ndarray
instead of IS-A ndarray)?
Hopefully someone with a bit more time will be more helpful and figure
out what is actually going on in your example, I'm sure it's some
wackily weird issue...
Nathaniel J. Smith -- http://vorpus.org
More information about the NumPy-Discussion