Skip to content

[Python] Int64Scalar and related instances should subclass the appropriate numbers abstract base class (abc) #50454

Description

@tswast

Describe the enhancement requested

The built-in numbers module provides abstract base classes for checking for various kinds of numbers. It would be helpful if pyarrow integer scalar values derived from these classes for more robust checks in code that might accept pyarrow values.

In [1]: import numpy as np

In [2]: import numbers

In [3]: isinstance(123, numbers.Integral)
Out[3]: True

In [6]: v = np.int64(123)

In [7]: isinstance(v, numbers.Integral)
Out[7]: True

In [8]: isinstance(v, int)
Out[8]: False

In [9]: import pyarrow as pa

In [10]: vv = pa.scalar(123)

In [11]: vv
Out[11]: <pyarrow.Int64Scalar: 123>

In [13]: isinstance(vv, numbers.Integral)
Out[13]: False

Component(s)

Python

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions