Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] Scalar subclasses should implement Python protocols #45653

Open
pitrou opened this issue Mar 3, 2025 · 3 comments
Open

[Python] Scalar subclasses should implement Python protocols #45653

pitrou opened this issue Mar 3, 2025 · 3 comments

Comments

@pitrou
Copy link
Member

pitrou commented Mar 3, 2025

Describe the enhancement requested

To make PyArrow scalars easier to use with non-PyArrow functions, we should define appropriate methods and protocols for specific scalar subclasses.

Examples:

  • integer scalars should implement __int__
  • floating-point scalars should implement __float__
  • binary scalars should implement __bytes__ and perhaps the buffer protocol
  • list-like scalars could implement Sequence
  • map scalars could implement Mapping
  • struct scalars could implement both Sequence and Mapping (?)

Note that some of this exists (unvoluntarily?) but is broken:

>>> a, b = pc.min_max([1,2,3])
>>> a  # expecting 1
'min'
>>> b  # expecting 3
'max'

Component(s)

Python

@pitrou
Copy link
Member Author

pitrou commented Mar 3, 2025

cc @AlenkaF

@thisisnic
Copy link
Member

Hey folks, @AlenkaF pointed me to this issue as a good place to get started contributing to PyArrow, so I was going to take a look at this. I might be a bit slow as I'll be spending some time getting acquainted with PyArrow in general, so I was going to spend the new few weeks looking at this. If there's any urgency, happy for someone else to take it off my hands though! :)

@thisisnic thisisnic self-assigned this Mar 10, 2025
@AlenkaF AlenkaF removed their assignment Mar 10, 2025
@pitrou
Copy link
Member Author

pitrou commented Mar 10, 2025

There's definitely no urgency here, feel free to take a stab at this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants