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

export Base.structdiff #34772

Open
tpapp opened this issue Feb 15, 2020 · 10 comments
Open

export Base.structdiff #34772

tpapp opened this issue Feb 15, 2020 · 10 comments
Labels
domain:collections Data structures holding multiple items, e.g. sets kind:feature Indicates new feature / enhancement requests

Comments

@tpapp
Copy link
Contributor

tpapp commented Feb 15, 2020

Base.structdiff was introduced more than 2 years ago in #24795, but not exported.

But since it is useful for efficient and type stable named tuple manipulation, it is now used by some packages working with NamedTuples, eg BangBang.jl, FunctionalTables.jl, NamedTupleTools.jl [these are just examples, I may have missed some packages].

It would be nice to have it exported, or at least officially declared part of the API.

@tkf @JeffreySarnoff

@JeffBezanson
Copy link
Sponsor Member

I'm ok with that. Maybe it needs a more general name, since it could also be extended to Dicts? (E.g. merge works for both dicts and named tuples)

@JeffreySarnoff
Copy link
Contributor

JeffreySarnoff commented Feb 17, 2020

We have setdiff "Construct the set of elements in s but not in any of the iterables in itrs"

setdiff(set, elem[s]togo), structdiff(struct, field[s]togo) and dictdiff(dict, key[s]togo) -->
seems like without(collective, item[s]togo)

a without x without(a, x)

@tkf
Copy link
Member

tkf commented Feb 17, 2020

Just brainstorming: keydiff, keysetdiff, antijoin

@JeffBezanson JeffBezanson added the domain:collections Data structures holding multiple items, e.g. sets label Feb 18, 2020
@JeffreySarnoff
Copy link
Contributor

bump

@JeffreySarnoff
Copy link
Contributor

JeffreySarnoff commented Feb 28, 2021

If naming is all that is in the way of this, perhaps omit or else keysdiff

@goretkin
Copy link
Contributor

goretkin commented Mar 1, 2021

Perhaps fleshing out the analogies is helpful

AstractSet NamedTuple / AbstractDict
identity keys
union merge
setdiff Base.structdiff, NamedTupleTools.delete
intersect NamedTupleTools.select

(The analogy can be loose because the second argument might be just a collection of keys, and not an association of keys and values)

Are there more?

I think key should be in the name since keys generalizes keys(::AbstractDict) and propertynames(::NamedTuple). Or perhaps pair should be in the name. pairdiff?

@JeffreySarnoff
Copy link
Contributor

For AbstractDict and for NamedTuple, the action in lines 2:4 of your table involves maintaining an association of key[s] with value[s] (even when keeping the association removes some key-value associands from the result or replaces some key-value pair by changing the value). For that reason, pairdiff (or more readably pairsdiff) works for me. (This operation is not limited to key interactions, it seems to me.)

@JeffreySarnoff
Copy link
Contributor

or diffkeys or really anything that this thread finds ameanable

@Eben60
Copy link

Eben60 commented Feb 20, 2024

bump

@vtjnash vtjnash added the kind:feature Indicates new feature / enhancement requests label Feb 20, 2024
@vtjnash
Copy link
Sponsor Member

vtjnash commented Feb 20, 2024

Please do not bump feature request issues, unless you have a PR for itt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:collections Data structures holding multiple items, e.g. sets kind:feature Indicates new feature / enhancement requests
Projects
None yet
Development

No branches or pull requests

7 participants