On Wed, 5 Jun 2019 at 09:06, Yanghao Hua email@example.com wrote:
With my very limited understanding of cpython internals (at least when I implement <==) it seems cpython is searching for an operator and then translates it into a method call on the objects
Not really. The valid operators are hard coded into the parser and lexer (see https://docs.python.org/3/reference/lexical_analysis.html#operators and https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bi... onwards) and there's no way at runtime for the user to introduce a new operator. So any new operator requires a very low-level change to the core of Python itself. (Not necessarily a *hard* change, but you do have to build a custom Python interpreter). I suspect you know this (as you've implemented <==) so I'm not entirely clear why you think Scala's approach (which as I understand it allows arbitrary operator symbols to be defined at runtime, and is therefore different at a very fundamental level) is relevant.