[Numpy-discussion] numarray unfriendly to user defined types
jmiller at stsci.edu
Tue Sep 23 03:35:01 CDT 2003
On Mon, 2003-09-22 at 19:27, Tim Hochberg wrote:
> I actually have no idea how you plan to make keyword arguments work
> here, perhaps you could explain that in more detail. Metaclasses are
> overkill, but a mixin, marker class could be used. That is, when
> designing a class for use with numarray, one would derive a class from a
> marker class in numarray::
> class MyArrayLikeClass(numarray.DeferToMe):
> Hmmm. That's not too bad. Todd, what do you think about using this logic::
> def __mul__(self, operand):
> if isinstance(operand, DeferToMe):
I like the core idea a lot. My only doubt is whether forcing the use of
inheritance is appropriate / a good thing. We might also consider
spelling it like:
_numarray_defer_to_me = True
def __mul__(self, operand):
if hasattr(operand, "_numarray_defer_to_me"):
return ufunc.multiply(self, operand)
> The only case where I see a potential problem is an old-style
> C-extenstion that can't be subclassed. I think that might be a case of
> YAGNI though.
Sounds YAGNI to me.
> Avoiding registration is appealing.
Good to have this seconded.
All in all, great ideas!
Todd Miller <jmiller at stsci.edu>
More information about the Numpy-discussion