Skip to content

Make ExtensionDtype.construct_array_type a regular method #36126

Closed
@TomAugspurger

Description

@TomAugspurger

Currently ExtensionDtype.consruct_array_type is a classmethod. This makes it hard to use a single dtype with multiple array classes where the array type depends on some parameter of the dtype.

I'd like to change construct_array_type to be a regular method rather than a classmethod. AFAICT, this is fine for pandas since everywhere we use construct_array_type we have an instance rather than a type. It should be fine for 3rd party arrays to continue to use classmethods since you can call a classmethod on an instance. The API breaking change would be for 3rd-party code relying on ExtensionDtype.construct_array_type() working (i.e. calling it on the class).

My motivation is for allowing a parametrized StringDtype that can be used for either the current StringArray and an Arrow-backed StringArray.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExtensionArrayExtending pandas with custom dtypes or arrays.RefactorInternal refactoring of codeStringsString extension data type and string data

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions