Skip to content

ENH: dtype API needs an API slot for a single-element copy #24859

Open

Description

@ngoldbaum

Currently, users will see seg faults if a user-defined dtype is passed somewhere where copyswap is used internally to copy array elements.

If we require that user-defined dtypes implement a single-element copy operation we will be able to implement a default copyswap implementation for user-defined dtypes which can be used where copyswap is used internally in NumPy.

Activity

  1. added this to the 2.0.0 release milestone on Oct 4, 2023
  2. seberg commented on Oct 9, 2023

    @seberg
    Member

    There are two slightly different use-cases here. In most cases, where we need a single element copy, we actually need to copy many, which means preparation is useful/necessary. But in some we may not need it.

    The question is how we deal with allowing preparation (noting that for the majority of dtypes the preparation would be at best specializing for short copies or alignedness and it would be good if NumPy just provides that copy function for those without references at least.).

  3. seberg commented on Jan 31, 2024

    @seberg
    Member

    We should do this, but probably not a disaster if it's not in 2.0, I think.

  4. removed this from the 2.2.0 release milestone on Aug 7, 2024
  5. ngoldbaum commented on Feb 6, 2026

    @ngoldbaum
    MemberAuthor

    #30795 has some more motivating examples for how this is still annoying

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions