[Rcpp-devel] Call by reference
Dirk Eddelbuettel
edd at debian.org
Wed Jul 29 22:12:06 CEST 2015
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
--
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
More information about the Rcpp-devel
mailing list