[Numpy-discussion] Trouble subclassing ndarray

Elliot Hallmark Permafacture at gmail.com
Fri Apr 10 12:40:33 EDT 2015


> You have a typo in your __array_finalize__ it misses the last underscore,
that is probably why it is never called. About the infinite recursion, not
sure on first sight.

Oh gosh, it was the underscrore!  infinite recursion no longer.  I was
searching all over for a misspelled "_cacheable".

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

So, now that this works, I'm open to hear more about why this is an awful
idea (if it is).  Why might I regret this later?  And will this add object
creation overhead to every ufunc and slice or otherwise degrade performance?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150410/2b3ffb5c/attachment.html>


More information about the NumPy-Discussion mailing list