[SciPy-User] Matrix multiplication operator PEP

Matthew Brett matthew.brett at gmail.com
Sat Feb 22 22:08:10 EST 2014


Hi,

On Sat, Feb 22, 2014 at 6:57 PM, Sturla Molden <sturla.molden at gmail.com> wrote:
> Nathaniel Smith <njs at pobox.com> wrote:
>
>> Subclassing is likely to be the major counter-argument, so make sure you
>> shoot it down thoroughly.
>>
>> My question is what counterargument are you referring to when you say
>> "subclassing" :-). Is it the "you should just have both np.matrix and np.ndarray" argument?
>>
>
> Yes, exactly that, but perhaps from a more a more principal point of view:
> That subclassing and overloading the operator in a subclass is the more
> "pythonic" way to change the behavior of an operator. Whereas adding more
> syntactic bloat is unpythonic. So we have to explain why subclassing and
> operator overloading is insufficient.

Yes, we do need to explain why we need two '*' operators, one for
element-wise multiplication and one for matrix multiplication.
Sub-classing can't do that for us - as we've know well - we just one
replace one mult by the other.

Cheers,

Matthew



More information about the SciPy-User mailing list