Skip to content
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

Query Array ownership with isshared and isowner #47540

Closed
wants to merge 1 commit into from

Conversation

Tokazama
Copy link
Contributor

Resizing operations throw errors on shared arrays but there's currently no way to find this out until an error is thrown. isshared lets us know before execution that an array may be shared and isowner lets us know if the array is the original owner, potentially allowing "unsharing" data. (#47537).

This recently came up alongside discussion of other traits for characterizing this information at the type level (#46500).

Resizing operations throw errors on shared arrays but there's currently
no way to find this out until an error is thrown. `isshared` lets us
know before execution that an array may be shared and `isowner` lets us
know if the array is the original owner, potentially allowing
"unsharing" data.
@Tokazama
Copy link
Contributor Author

@Jutho, I know it's a bit late to be addressing this but thought you may be interested nonetheless

@Jutho
Copy link
Contributor

Jutho commented Nov 12, 2022

Pinging @dkarrasch , who is now maintaining LinearMaps.jl where this came up.

@brenhinkeller brenhinkeller added the arrays [a, r, r, a, y, s] label Nov 17, 2022
@Tokazama
Copy link
Contributor Author

@dkarrasch , I'm assuming that thumbs up means this is still useful?

This would also be good so we could start developing the interface for changing collection sizes. Then we could get have more generic user facing methods like

function push!(x::AbstractVector, item)
    isshared(x) || error("cannot resize array with shared data")
    unsafe_growend!(x, 1)
    unsafe_setindex!(x, item, x)
    return x
end

@dkarrasch
Copy link
Member

In LinearMaps.jl, we have an "ugly" try-catch-block to catch cases when some vector cannot be resized. It would be nice to replace this with a specific and clear predicate.

@Tokazama
Copy link
Contributor Author

Tokazama commented Nov 28, 2022

Whose the appropriate core dev to ping to get this moving forward?

This is the sort of thing I'd like to be able to do.

@vtjnash vtjnash closed this Oct 27, 2023
@vtjnash
Copy link
Member

vtjnash commented Oct 27, 2023

This error is now gone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays [a, r, r, a, y, s]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants