Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
WIP: Better copyto #172
WIP: Better copyto #172
Changes from 7 commits
5528a9a
5b5f565
e6a51fa
ff08d35
c0f3f61
b4e8089
35d103f
5c5e571
89ed2e4
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't you just use
remap[s] == -1
as a sentinel?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I have done first, but allocating
seen
should be cheap, and the problem is thatremap
, in order to be fast, should have the same eltype asdrefs
and they are unsigned.At least this is what I thought. Now I see that we can use
remap[s] == 0
as sentinel, as we use0
for missing which is handled in other way anyway. I will change thisThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure we need to duplicate all of this code for performance? Branch prediction is usually quite efficient, so even if you have an
if
inside the loop I suspect it won't make a big difference. And often LLVM will do the hoisting automatically.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have to do
isordered
check in the innermost part of the loop. I can check if compiler can optimize this out.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there's already a branch I don't think it will matter, even if the compiler doesn't hoist it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but we have to do
isordered
test in every step of the loop. If it is not optimized out then it will be much slower. I will check.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method isn't needed now AFAICT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you want to happen if we want to
copy!
a normal array to a categorical array? Throw an error?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why Base doesn't call
resize!
in case of failure. That sounds trivial, undoing the operation is not as hard as incopyto!
. But better stick to what Base does, and maybe file an issue in Julia.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the reason is that you would have to do try-catch which will slow down the function? I will open an issue with Base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better check the length? Actually, better check the whole contents of the result (same for the line above).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better use unsorted values to really test that the order is preserved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not also check levels? Also with different unsorted values? Same below.