[Python-ideas] [RFC] draft PEP: Dedicated infix operators for matrix multiplication and matrix power
Antoine Pitrou
solipsis at pitrou.net
Sat Mar 15 16:22:33 CET 2014
On Sun, 16 Mar 2014 02:11:43 +1100
Steven D'Aprano <steve at pearwood.info> wrote:
> > The possible reason given in the PEP is very weak and amounts to
> > premature optimization:
>
> I don't think it's premature optimization. Sometimes we do know ahead of
> time that a calculation done one way will be faster than doing it
> another way: you don't have to "try it and see" to realise that
> repeatedly adding strings in a for-loop can be O(N**2) versus O(N) for
> using str.join().
It's premature optimization because the PEP is proposing to enforce it
at the language level. We didn't change *the language* so that "str +="
allows for O(N) repeated concatenation; instead we tell people that
"".join() should be used for repeated concatenation. Why would our
course of action be different for matrix multiplication?
Regards
Antoine.
More information about the Python-ideas
mailing list