Skip to content

[Python] Refactor the Scalar classes #25134

Description

@asfimport

The situation regarding scalars in Python is currently not optimal.

We have two different "types" of scalars:

  • ArrayValue(Scalar) (and subclasses of that for all types): this is used when you access a single element of an array (eg arr[0])

  • ScalarValue(Scalar) (and subclasses of that for some types): this is used when wrapping a C++ scalar into a python scalar, eg when you get back a scalar from a reduction like arr.sum().

    And while we have two versions of scalars, neither of them can actually easily be used as scalar as they both can't be constructed from a python scalar (there is no scalar(1) function to use when calling a kernel, for example).

    I think we should try to unify those scalar classes? (which probably means getting rid of the ArrayValue scalar)

    In addition, there is an issue of trying to re-use python scalar <-> arrow conversion code, as this is also logic for this in the python_to_arrow.cc code. But this is probably a bigger change. cc @kszucs

Reporter: Joris Van den Bossche / @jorisvandenbossche
Assignee: Krisztian Szucs / @kszucs

Related issues:

PRs and other links:

Note: This issue was originally created as ARROW-9017. Please see the migration documentation for further details.

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