Skip to content

[Python] Scalar subclasses should implement Python protocols #45653

Description

@pitrou

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

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions