[Numpy-discussion] core library structure

Lluís xscript at gmx.net
Fri Feb 4 14:23:42 EST 2011


Darren Dale writes:

> With generic functions, you wouldn't have to remember to use the ufunc
> provided by masked array for one type, or the default numpy for
> another type.

Sorry, but I don't see how generic functions should be a better approach
compared to redefining methods on masked_array [1]. In both cases you
have to define them one-by-one.

[1] assuming 'np.foo' and 'ma.foo' (which would now be obsolete) simply
    call 'instance.foo', which in the ndarray level is the 'foo' ufunc
    object.

Well, yes. I do see an advantage, if the number of methods grows too
large (which is probably what started your concerns).


Where I do see a utility for generic functions is as cross-cutting
points for class-oblivious extensions, like deferred evaluation
(although then you lose concise and per-object control of when to
enable/disable deferred evaluation). But then you need "implicitly
chained" implementations for the generic functions (which might lead to
poor performance, I just don't know).


Lluis

--
 "And it's much the same thing with knowledge, for whenever you learn
 something new, the whole world becomes that much richer."
 -- The Princess of Pure Reason, as told by Norton Juster in The Phantom
 Tollbooth



More information about the NumPy-Discussion mailing list