[Python] Int64Scalar and related instances should subclass the appropriate numbers abstract base class (abc)
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 88
Description
### Describe the enhancement requested
The built-in [numbers module](https://docs.python.org/3/library/numbers.html#module-numbers) 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]:
In [13]: isinstance(vv, numbers.Integral)
Out[13]: False
```
### Component(s)
Python
Contributor guide
Research direction
Start in the Python component by reproducing the issue's numbers.Integral check with pyarrow.Int64Scalar and comparing it with NumPy. Trace the Python scalar implementation and existing tests to identify the related integer scalar types and appropriate abstract base classes. Done means the relevant scalar instances pass the expected numbers-module checks with regression coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100