List replication operator

Alexandre Brault abrault at mapgears.com
Fri May 25 12:11:04 EDT 2018



On 2018-05-25 11:40 AM, bartc wrote:
> On 25/05/2018 16:27, Chris Angelico wrote:
>> You're way WAY too late to debate the matrix multiplication operator.
>
> /The/ matrix multiplication operator?
>
> In which language? And what was wrong with "*"?
>
In Python, the language we're discussing right now. What was wrong with
* is described in detail in PEP 465

> (I've implemented matrix multiply in a language (although for
> specialised matrix types), and I used the same "*" symbol as was used
> to multiply anything else.)
>
> Anyway this is not matrix multiplication, but replication, and using
> '@' seems more a consequence of there not being any better ones
> available as they are already used for other things.
>
You're right, it's not matrix multiplication. And Pathlib's use of / is
not division, nor do C++'s streams use bitshifting.
But overloading the matmul operator would allow this feature to work
without changing the syntax of the language, nor breaking existing code
(since no built-in types implement __matmul__).



More information about the Python-list mailing list