Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

`asarray` with `copy=False` produces new array?

Open
#1,009 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
50/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python
Domain
documentation

Research direction

Start by comparing the specification wording for asarray and astype with the examples in the issue, then check how the existing standard text addresses object identity versus shared memory. Done means resolving whether copy=False requires returning the same array object and making the specification unambiguous.

Written by the indexing model from the issue text.

Description

This may be related to gh-788, but I think it is distinct.

The behavior of astype with copy=False is:

If False and the specified dtype matches the data type of the input array, the input array must be returned...

So this passes:

import array_api_strict as xp
dtype = xp.int64
x = xp.asarray([1, 2, 3], dtype=dtype)

y = xp.astype(x, dtype, copy=False)
assert y is x 

For asarray:

If False, the function must never copy for input which supports the buffer protocol...

Here, it is not explicit whether "must never copy" refers to the array object itself or the underlying memory buffer. In any case, array_api_strict creates a new array object, so the equivalent assertion fails.

y = xp.asarray(x, dtype=dtype, copy=False)
assert y is x 
# AssertionError: 

Is "must never copy" intended to allow the returned object to be different from the input? Either way, should it be more explicit?
If it helps, NumPy, PyTorch, JAX, and Dask all pass both assertions.

Dominant language
Python
Stars
281
Forks
52
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from data-apis/array-api

All issues in data-apis/array-api

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.