[Rcpp-devel] Rcpp-devel Digest, Vol 64, Issue 16

Christian Gunning xian at unm.edu
Thu Feb 26 23:05:14 CET 2015


I thought I'd step in and grab this one :)

"In general, it's certainly a reasonable point that there is a trade-off
to be made -- user-friendliness against the potential extra copies (not
sure whether this has ever been measured -- as in counting the cases of
`clone`-less existing code-bases where this was the actual performance
bottleneck)."

Short answer is yes, benefits are well documented via the list.  In
short, the relative effect size grows with the size of the object
cloned, and the number of times cloned.  As you might expect.  It's
pretty easy to cook up a trivial example to test this for yourself -
try summing a 1e3*1e3 matrix 1e4 times, for example.

"That being said, as for the "what to do by default" advice, for anyone
finding themselves in a need to `clone` -- `std::vector<double>` seems
like the safer, better documented option."

R.e. "default options", do things work as you expect if you follow
const-correctness?
http://isocpp.org/wiki/faq/const-correctness
It seems like one option is to tell the compiler what you want *not*
changed (forcing you to clone anything that should be changed).  This
is a genuine question.

To answer your implied concerns:

* Yes, that ship has sailed.  Many packages use Rcpp, and it's been
around for years.

* Rcpp is much *easier* than writing C code for R.  There's a minimum
expectation of developer experience for Rcpp users.  That minimum
level is way *lower* than alternate high-performance R/C integration
methods, but some google-fu / gmane searching is not an unreasonable
request.

* Rcpp is the work of a relatively small number of individuals working
on a mostly (all?) volunteer basis.  If you don't like the tools,
you're welcome to make something else.
http://xkcd.com/927/

* Yes, the in-R documentation of is sometimes lacking (e.g.,
?"Rcpp::NumericVector").  The mailing list support, however, is
generally very responsive, and is considered congenial compared to
R-help.  In addition, there are a number of published manuscripts,
vignettes, unit-tests, and a gallery.  Again, you're welcome to help
organize this, write help manuals for R, etc.

hth,
-Christian

-- 
A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal – Panama!


More information about the Rcpp-devel mailing list