[Python-ideas] [RFC] draft PEP: Dedicated infix operators for matrix multiplication and matrix power

Ethan Furman ethan at stoneleaf.us
Fri Mar 14 15:13:27 CET 2014


On 03/14/2014 04:48 AM, M.-A. Lemburg wrote:
> On 14.03.2014 12:25, Robert Kern wrote:
>>
>> RSR = R.dot(var_beta.dot(R.T))
>> RSR = R @ var_beta @ R.T
>>
>> xx_inv.dot(xeps.dot(xx_inv))
>> xx_inv @ xeps @ xx_inv
>>
>> dF2lower_dper.dot(F2lower.T) + F2lower.dot(dF2lower_dper.T) - 4/period*F2lower.dot(F2lower.T)
>> dF2lower_dper @ F2lower.T + F2lower @ dF2lower_dper.T - 4/period*(F2lower @ F2lower.T)
>>
>> dFX_dper.dot(Gi.dot(FX2.T)) - FX.dot(Gi.dot(dG_dper.dot(Gi.dot(FX2.T)))) + FX.dot(Gi.dot(dFX2_dper.T))
>> (dFX_dper @ Gi @ FX2.T) - (FX @ Gi @ dG_dper @ Gi @ FX2.T) + (FX @ G @ dFX2_dper.T)
>>
>> torient_inv.dot(tdof).dot(torient).dot(self.vertices[parent].meta['key']))
>> (((torient_inv @ tdof) @ torient) @ self.vertices[parent].meta['key']
>
> This doesn't look very readable to me - the operator saves you
> a few parens in some situations, but as in the last example, it can
> also require adding new ones.

The difference being that grouping parens are easier to read and are less visual clutter than calling parens.

--
~Ethan~


More information about the Python-ideas mailing list