Open
Description
Currently, the way to call Python operators from Chapel is to explicitly call the dunder method
use Python;
var interp = new Interpreter();
var pyInt1 = interp.toPython(10);
var pyInt2 = interp.toPython(11);
var res = pyInt1.call("__add__", pyInt2);
While this is a simple/silly example with plain integers, many libraries overload these dunder methods in interesting ways to create their user interfaces. Translitering these libraries in Chapel-Python interop can be awkward because of these dunder method calls.
However, we could support many of these Python operators as Chapel operators. For example
operator +(lhs: owned Value, rhs: owned Value) {
return lhs.call("__add__", rhs);
}
I think we should support as many of these dunder methods as we can