You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Python] Consider adding reflected arithmetic operators to Scalar and Array #55893
Scalar and Array define the forward operators (s + 1), so a Python number on the left (1 + s ) raises TypeError:
importpyarrowaspas=pa.scalar(1)
s+1# <pyarrow.Int64Scalar: 2>1+s# TypeError: unsupported operand type(s) for +: 'int' and 'pyarrow.lib.Int64Scalar'
The same for pa.array([1]) + 1 versus 1 + pa.array([1]).
Adding __radd__, __rsub__, __rmul__, __rtruediv__, __rpow__, __rand__, __ror__, __rxor__, __rlshift__ and __rrshift__ would make both forms work.
Type annotations would then need the same additional methods.
Activity
apacheGH-55893: Add the ASF license header to the regression tests
apacheGH-55893: Place reflected arithmetic checks in the existing tests