[Rcpp-devel] Call by reference

Dirk Eddelbuettel edd at debian.org
Wed Jul 29 19:37:37 CEST 2015

On 29 July 2015 at 17:28, Rguy wrote:
| The reason I am interested in using call by reference is that I am accessing
| data frames with over a million rows and hundreds of columns. It is more
| efficient to operate on such a data frame directly, as opposed to copying it
| into and out of a function. In other words, I want to be *not* like R, which is
| why I am interested in utilizing C++, which supports call by reference.

You misunderstand.  We communicate by SEXP.  Where the P stands for pointer.
IE even with 

  R> M <- as.data.frame(matrix(rnorm(1e6, 1e3)))
  R> object.size(M)
  8000672 bytes

we'd still only pass the same 56 bytes a SEXP takes. See eg
https://cran.r-project.org/doc/manuals/R-ints.html#SEXPs and play with memory
profiling in R.


http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org

More information about the Rcpp-devel mailing list