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

add replace methods for Tuple #38216

Merged
merged 2 commits into from
Dec 9, 2020
Merged

add replace methods for Tuple #38216

merged 2 commits into from
Dec 9, 2020

Conversation

rfourquet
Copy link
Member

Closes #33782:

julia> replace((1, 2, 3, 4), 3 => 7)
(1, 2, 7, 4)

This must be squashed, but the first commit contains specialized implementations for small tuples, it seems useless so I deleted them, but wanted to keep it archived here, just in case :)
I spent one hour trying understand how performance works, with @inline or not, for different sizes of tuples, with or without keyword, with or without deferring to map when count >= length(tuple)... I failed, so ended up without any @inline, this has decent performance.

@rfourquet rfourquet added the collections Data structures holding multiple items, e.g. sets label Oct 28, 2020
@rfourquet
Copy link
Member Author

Bump

@StefanKarpinski StefanKarpinski added the triage This should be discussed on a triage call label Dec 1, 2020
base/set.jl Outdated

### replace for tuples

_replace(f::Callable, t::Tuple, count::Int) =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use the function keyword form.

@JeffBezanson
Copy link
Member

From triage: we don't have a good way to implement this now, but the same holds for many tuple functions, so we might as well add this.

@JeffBezanson JeffBezanson removed the triage This should be discussed on a triage call label Dec 3, 2020
@Keno Keno merged commit 75a3d31 into master Dec 9, 2020
@Keno Keno deleted the rf/replace-tuple branch December 9, 2020 19:14
ElOceanografo pushed a commit to ElOceanografo/julia that referenced this pull request May 4, 2021
* verbose replace for Tuple

* add replace methods for Tuple
rfourquet added a commit that referenced this pull request Jul 25, 2021
KristofferC pushed a commit that referenced this pull request Jul 28, 2021
rfourquet added a commit that referenced this pull request Jul 31, 2021
rfourquet added a commit that referenced this pull request Aug 13, 2021
vtjnash pushed a commit that referenced this pull request Aug 18, 2021
The methods were added in #38216.

(cherry-picked from 57ce0e6, PR #41701)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
collections Data structures holding multiple items, e.g. sets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

replace function doesn't work on Tuples
4 participants