For the new vctrs::records class, I implemented length, names, [[, and [[<- myself in https://github.com/r-lib/vctrs/blob/master/src/fields.c. That lets me override the default S3 methods while still being able to access the underlying data that I'm interested in.
Another option that avoids (that you should never discuss in public 😉) is temporarily setting the object bit to FALSE. In the long run, I think an ALTREP vector that exposes the underlying data of an S3 object (i.e. sans attributes apart from names) is probably the way forward. Hadley On Fri, Aug 24, 2018 at 1:03 PM Henrik Bengtsson <henrik.bengts...@gmail.com> wrote: > > Is there a low-level function that returns the length of an object 'x' > - the length that for instance .subset(x) and .subset2(x) see? An > obvious candidate would be to use: > > .length <- function(x) length(unclass(x)) > > However, I'm concerned that calling unclass(x) may trigger an > expensive copy internally in some cases. Is that concern unfounded? > > Thxs, > > Henrik > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel -- http://hadley.nz ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel