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.
I'm hoping to move some of the list-of code to C, since I am using that more internally in tidyr, but that requires moving
new_vctr()
to C. So this PR does that.A few notes:
new_data_frame()
and used.External()
, which seemed best for working with...
new_data_frame()
, supplyingnames =
as an attribute now overrides existing namesclass =
in...
due to theclass
argument, but I check that in case we ever make these dots dynamicnames_repair_missing()
to C, but that was straightforwardRf_shallow_duplicate_attr()
, which creates an ALTREP wrapper around an object if you plan on just updating its attributes. That makes setting attributes extremely lightweight and fast. That is available throughattributes<-
, which is whatvec_set_attributes()
does on R >=3.6, so we call back to R to be able to call that.We have tried to keep
<vctrs_vctr>
out of the main codebase, and I think this still accomplishes that. There is nothing here that couldn't be moved to a standalone package - which I think is the right way to think about where C code can interact with the vctr type.Here is a benchmark showing fairly minor improvements in performance. I think this will be helpful in the long run, since
new_vctr()
will be called a lot (like in a reduction ofvec_ptype2()
calls where the result of each call tovec_ptype2()
callsnew_vctr()
, which is what list-of does).Created on 2021-11-17 by the reprex package (v2.0.1)