Skip to content
Prev 8892 / 10988 Next

[Rcpp-devel] Call by reference

On 29 July 2015 at 13:05, Nathan Kurz wrote:
| I tried memory profiling both of your versions with a long vector, and
| found that the recommended Rcpp approach made an additional 8GB copy.
| Is there a way to avoid this extra copy without resorting to in place
| modification?

Look at Rcpp::XPtr for the most fine-grained control.  We have used that to
pass bigmemory object handles around.

| nate at ubuntu:~/R/byreference$ less abs.R
|   library(Rcpp)
| 
|   cppFunction("NumericVector absCopy(NumericVector & x) { return abs(x); }")

Copy-on-write semantics. *If* you alter you create copies.


All this is becoming a wee bit obscure.  The focus of the list is to help
people use R, not to navigate constraints built into the R system.

Dirk