From: Paul F D. <pa...@pf...> - 2003-01-24 20:35:33
|
Every time the subject of subclassing a numeric array comes up, it as if nobody ever thought of it before. Been there, done that. It doesn't turn = out to be all that useful. To see why, consider a + b where a and b are Foo instances, and Foo inherits from numarray. a. a + b will be a numarray, not a Foo instance, unless you write a new = + operator. b. Attempting to have numarray itself apply a subclass constructor to = the result runs into the problem that numarray does not have any idea what = the constructor's signature is or what information is needed to fill out = that constructor. c. Even if the subclass accepts numarray's constructor signature, it = would rarely produced satisfactory results just "losing" the Foo'ness details = of a and b. This same argument applies to every method that returns a Foo instance, = and every ufunc. So you end up redoing everything anyway. In short, worrying about subclassing is way down the list of things we = ought to consider.=20 > -----Original Message----- > From: num...@li...=20 > [mailto:num...@li...] On=20 > Behalf Of Konrad Hinsen > Sent: Friday, January 24, 2003 12:07 PM > To: Jos=E9 Fonseca > Cc: num...@li... > Subject: Re: [Numpy-discussion] Extensive use of methods=20 > instead of functions >=20 >=20 > Jos=E9 Fonseca <j_r...@ya...> writes: >=20 > > With the ability of subclassing types in recent versions of=20 > the Python=20 > > language, more people will be interested in subclassing=20 > Numeric arrays=20 > > for specific purposes. Still the use of functions instead=20 > of methods=20 > > takes away many of the advantages, the ability of being overloaded. >=20 > True. On the other hand, there is also an advantage: NumPy=20 > routines can be used on standard Python data types such as=20 > number and sequence types. >=20 > In the ideal world (which might come one day), core NumPy=20 > functionality would be part of standard Python, and then all=20 > these operations would work on other built-in types as well. >=20 > Until then, I am not sure that changing NumPy functions to=20 > methods is a good idea. I need to call them on scalar numbers=20 > much more often than I subclass arrays. >=20 > Konrad. > --=20 > -------------------------------------------------------------- > ----------------- > Konrad Hinsen | E-Mail:=20 > hi...@cn... > Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 > Rue Charles Sadron | Fax: +33-2.38.63.15.17 > 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ > France | Nederlands/Francais > -------------------------------------------------------------- > ----------------- >=20 >=20 > ------------------------------------------------------- > This SF.NET email is sponsored by: > SourceForge Enterprise Edition + IBM + LinuxWorld =3Domething 2=20 > See! http://www.vasoftware.com=20 > _______________________________________________ > Numpy-discussion mailing list Num...@li... > https://lists.sourceforge.net/lists/listinfo/numpy-discussion >=20 |