Skip to content

fix circshift(::Tuple{}, ::Int)#54295

Merged
oscardssmith merged 10 commits into
JuliaLang:masterfrom
nsajko:empty_tuple_circshift
Jun 8, 2024
Merged

fix circshift(::Tuple{}, ::Int)#54295
oscardssmith merged 10 commits into
JuliaLang:masterfrom
nsajko:empty_tuple_circshift

Conversation

@nsajko
Copy link
Copy Markdown
Member

@nsajko nsajko commented Apr 28, 2024

Fixes circshift for empty tuples.

Fixes #54294

@nsajko nsajko added bugfix This change fixes an existing bug collections Data structures holding multiple items, e.g. sets performance Must go faster labels Apr 28, 2024
@adienes
Copy link
Copy Markdown
Member

adienes commented Apr 29, 2024

circshift2(t::Tuple{L,R}, shift::Integer) where {L,R} = ifelse(iseven(shift), t, reverse(t))

is a bit faster on my machine than the length-2 implementation added here (just ifelse vs if-else mostly. not sure if the extra type assertions are needed either)

@nsajko
Copy link
Copy Markdown
Member Author

nsajko commented Apr 29, 2024

I think ifelse is only a good idea when L == R, otherwise it exacerbates type stability issues. I guess.

@nsajko
Copy link
Copy Markdown
Member Author

nsajko commented May 6, 2024

ping

@nsajko nsajko force-pushed the empty_tuple_circshift branch from fecd485 to 7c7e83d Compare May 14, 2024 13:38
@nsajko
Copy link
Copy Markdown
Member Author

nsajko commented May 18, 2024

ping

1 similar comment
@nsajko
Copy link
Copy Markdown
Member Author

nsajko commented May 31, 2024

ping

@nsajko
Copy link
Copy Markdown
Member Author

nsajko commented Jun 8, 2024

ping, this should be very easy to review (don't look at the individual commits)

@oscardssmith oscardssmith merged commit f305e9e into JuliaLang:master Jun 8, 2024
@nsajko nsajko deleted the empty_tuple_circshift branch June 8, 2024 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix This change fixes an existing bug collections Data structures holding multiple items, e.g. sets performance Must go faster

Projects

None yet

Development

Successfully merging this pull request may close these issues.

circshift(::Tuple{}, ::Int) throws DivideError instead of returning

3 participants