Skip to content

[Python] Support operator % on Array/Scalar #55659

Open

Description

@tadeja

Describe the enhancement requested

Arithmetic and bitwise operators to Array and Scalar were added in

import pyarrow as pa
pa.array([9,-9]) % 3
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    pa.array([9,-9]) % 3
    ~~~~~~~~~~~~~~~~~^~~
TypeError: unsupported operand type(s) for %: 'pyarrow.lib.Int64Array' and 'int'

Now that modulo / modulo_checked exist since #46901 (floored like Python's %) the implementation of __mod__ could call modulo_checked - similar to other operators calling their own checked kernels.

Note

if implemented, the annotation stubs will need __mod__ added as well (per current state of #55264 as one more alias line in array.pyi __mod__ = __add__)
(and % may be re-added where just removed in #55654)

Component(s)

Python

Activity

  1. AnuragRaut08 commented on Nov 18, 2026

    @AnuragRaut08
    Contributor

    I'll take a look at this and work on implementing % support for Array and Scalar, including the corresponding type stubs and tests.

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