On Sun, Mar 23, 2014 at 06:47:40PM -0700, Devin Jeanpierre wrote:
I'm not sure such a thing would happen with an operator for which the stdlib and documentation and everything insists is only for matrix multiplication.
They would *insist* would they? The documentation would come with a great warning "Thou Shalt Not Use __matmul__ For Anything Except Matrix Multiplication"? I suppose that will be like the similar (imaginary) warning that __pow__ is only permitted to be used for numerical exponentiation and that any other use is forbidden on pain of being slapped with a fish. I think it is highly unlikely that people will be frightened off from overloading @ by the name. If people happily use __lt__ for subset checking, which is *nothing* like less-than, I'm sure they'll use @ as well. People do far weirder things -- there's even a recipe out there on the Internet for implementing arbitrary named pseudo-operators using __or__ : vector |dot| vector But suppose you're right, and people don't use it for anything but matrix multiplication. So what? Who cares? It's not like anyone is made worse off by the change. None of my code currently uses the @ operator. If numpy starts to use it, and I don't, I'll be no worse off than I am now.
It'd be like if we had "__twos_complement_bitwise_and__".
Having __matmul__ would be like if we had __xor__ __pow__ __sub__ __div__ __mod__ __pos__ or __neg__ -- Steven