Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Great! Minor quibble: the underlying method names should not mention `mat` (e.g. `__matmul__`); instead mentioning the shape of the operator (e.g. `__atmul__`).


that might be a good idea, or a little strange.

many existing python infix boolean operators resolve to method names based on the meaning, rather than the symbol. e.g. `a + b` resolves to `a.__add__(b)` rather than `a.__plus__(b)`, `x * * y` resolves to `x.__pow__(y)` rather than `x.__asteriskasterisk__(y)`, say. so arguably it would be consistent to name @ after the common meaning also.

http://docs.python.org/2/reference/datamodel.html#emulating-...

on the other hand, "consistency is not necessarily a virtue: one can be consistently obnoxious" - C.A.B. Smith

that said, i like the idea that @ should be more general than just for matrices. an arbitrary infix boolean operation, neither necessarily commutative nor invertible.

even when talking about matrix multiplication, generalising slightly from arrays to abstract elements of vector spaces, and from matrices to linear transformations between vector spaces leaves you writing the same kinds of expressions that compose linear transformations without anything necessarily being represented as a matrix.


This. It allows for the general meaning to be conveyed (it's numeric, kind of multiplicative, uses @ symbol) without restricting it to a particular use case. This allows other users to define their own meanings for @ in a variety of contexts.

We could even have a reverse mnemonic: AlTernate Multiplication




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: