API: `asarray` API for `copy=...` kwarg
See original GitHub issueThere was a plan to update NumPy’s asarray
’s copy
kwarg, however, this would mismatch with the array
one. NumPy was currently aiming for possibly having an enum or maybe copy="never"
, but not a False/True/None
flags.
I am a bit unclear about the desired API right now, since on NumPy it was explicitly argued against the True/False/None
choice.
@charris has also brought up the idea to add a “please do not copy this array” flag to the array object itself to prevent accidental copy of large arrays.
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Imageio's developer API — imageio 2.9.0 documentation
Pypy's np.asarray consumes a lot of memory if the given array is an ndarray ... If True, the file will be downloaded even...
Read more >API: how to handle NA in conversion to numpy arrays #30038
In #29964 and #29961 NA in IntegerArray and BooleanArray), the question comes up how to handle pd.NA's in conversion to numpy arrays.
Read more >Splat operators in JavaScript, equivalent to *args and ...
I use Python a lot, and I am just quickly learning JavaScript right now (or should I say re-learning). So, I wanted to...
Read more >mediapy API documentation - Google
Package mediapy. mediapy : Read/write/show images and videos in an IPython/Jupyter notebook. [GitHub source] [API docs] [PyPI package] [Colab example].
Read more >iarray.asarray — ironArray for Python 2022.3-$IA_BUILD_VER ...
iarray.asarray(obj: Union[IArray, bool, int, float, NestedSequence, Any], ... copy: Optional[bool] = None, cfg: Optional[Config] = None, **kwargs) → IArray ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, I was advocating for enums last time 🤦
I commented on the mailing list discussion advocating for True/False/None.
I think 3-way True/False/None is a totally reasonable solution if we are designing this API from scratch.
The problem is that right now
copy=False
means “copy if needed” for NumPy, which is not what we would wantcopy=False
to mean in the array API.If we want to change what
copy=False
means, we’ll need a deprecation cycle in NumPy. That would be somewhat distruptive, but on the whole, it might be a good thing – it would turn up lots of cases where users are probably mistaken about whatcopy=False
means. Also this would a relatively smooth deprecation, because there’s an easy backwards compatible work-around (just setcopy=None
instead) and we would not be changing the behavior of existing code beyond starting to raise an error message in some cases.