Skip to content

[Python] Consider adding reflected arithmetic operators to Scalar and Array #55893

Backlog

Description

@tadeja

Describe the enhancement requested

Scalar and Array define the forward operators (s + 1), so a Python number on the left (1 + s ) raises TypeError:

import pyarrow as pa

s = 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.

Follow-up to

Component(s)

Python

Component(s)

Python

Activity

  1. added 2 commits that reference this issue on Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions