[Numpy-discussion] copy="never" discussion and no deprecation cycle?

Eric Wieser wieser.eric+numpy at gmail.com
Wed Jun 16 18:10:54 EDT 2021


I agree with Stephan, but even 3 seems dangerous to me. Any code that wraps
a numpy function and accepts a `copy` parameter (especially
`__array_function__`) is likely to contain `if copy` somewhere, which would
result in entirely (but likely silently) the wrong behavior for
`copy="never"`. An important reason for the original `np.never_copy`
suggestion the first time this was discussed is that it can overload
`__bool__` to raise or return `False` and warn, which would make silent bad
behavior visible one way or another.

I think a short NEP might be in order here, just so we can make sure we've
addressed everything that came up the previous time this was discussed.

Eric.



On Wed, Jun 16, 2021, 23:00 Stephan Hoyer <shoyer at gmail.com> wrote:

> On Wed, Jun 16, 2021 at 1:01 PM Sebastian Berg <sebastian at sipsolutions.net>
> wrote:
>
>> 2. We introduce `copy="never"`, `copy="if_needed"` and `copy="always"`
>>    as strings (all other strings will be a `TypeError`):
>>
>>    * Problem: `copy="never"` currently means `copy=True` (the opposite)
>>                Which means new code has to take care when it may run on
>>                older NumPy versions.  And in theory could make old code
>>                return the wrong thing.
>>
>
> To me, this seems like a big problem.
>
> People try to use newer NumPy features on old versions of NumPy all the
> time. This works out OK if they get error messages, but we shouldn't add
> new features that silently do something else on old versions -- especially
> for recent old versions.
>
> In particular, both copy='if_needed' and copy='never' would mean
> copy='always' on old versions of NumPy. This seems bad -- basically the
> exact opposite of what the user explicitly requested. These sort of bugs
> can be quite challenging to track down.
>
> So in my opinion (1) and (3) are the only real options.
>
>
>> 3. Same as 2. But we take it very slow: Make strings an error right now
>>    and only introduce the new options after two releases as per typical
>>    deprecation policy.
>>
>>
>> ## Discussion
>>
>> We discussed it briefly today in the triage call and we were leaning
>> towards strings.
>>
>> I was honestly expecting to converge to option 3 to avoid compatibility
>> issues (mainly surprises with `copy="never"` on older versions).
>> But considering how weird it is to currently pass `copy="never"`, the
>> question was whether we should not change it with a release note.
>>
>> The probability of someone currently passing exactly one of those three
>> (and no other) strings seems exceedingly small.
>>
>> Personally, I don't have a much of an opinion.  But if *nobody* voices
>> any concern about just changing the meaning of the string inputs, I
>> think the current default may be to just do it.
>>
>> Cheers,
>>
>> Sebastian
>>
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion at python.org
>> https://mail.python.org/mailman/listinfo/numpy-discussion
>>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/numpy-discussion/attachments/20210616/3c4df48a/attachment.html>


More information about the NumPy-Discussion mailing list