-
Notifications
You must be signed in to change notification settings - Fork 50
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
RFC: add copy
#495
Comments
Thanks @jakirkham. A couple of thoughts:
|
Isn't this |
To summarize the ask, library functions handling general arrays may want to copy as they want an array they can mutate safely without affecting user provided data. We concluded that we want a function (not a method) and one needs to do a namespace lookup ( There is a separate question of what we call it. Either a new function (
|
Right now |
@asmeurer good point. Maybe something like "must ensure that the returned array does not share data with another array, either by copying the data to a new memory location or in some other way (e.g., this property is guaranteed by design)". |
IMO this doesn't need to be added to the standard. In SciPy we use a private function called |
…owing mutation Ref: data-apis#495
I've opened #886 to hopefully satisfy concerns raised here and elsewhere: an array which can be mutated without affecting user data and allowing libraries such as JAX to avoid performing an explicit copy, which is unnecessary when provided a known array type. |
Some array libraries implement a
.copy()
method (like NumPy). While there are some indirect ways to get at this now (asarray
,reshape
, etc.), currently the API lacks a way to do this directly and without other potential side-effects. Should add a method (unlike a function) would ensure the new array has the original array's type simply. Curious if there is appetite for including this in the API.Related is a question of what interplay there is with
__copy__
and/or__deepcopy__
(if any).The text was updated successfully, but these errors were encountered: