[Rcpp-devel] R vectorisation vs. C++ vectorisation

Hadley Wickham h.wickham at gmail.com
Tue Nov 20 16:59:23 CET 2012


> In my case, informed by interesting benchmarks such as yours, I now tend
> to write my R functions with optimizing to C++ in mind. In other words,
> I've stopped being ashamed of having loops in my R code.
>
> If my R script completes Quick Enough I don't care. But when it takes
> Too Long, I know I can improve it by one order of magnitude by writing
> better R code, or by two orders of magnitude by porting just the
> bottleneck to C++, using Rcpp and inline. For me, at least, those two
> choices are about equal effort.

I think that's what pragmatic optimisation is all about - you want to
minimise code writing + code execution time. Optimising code execution
time alone is potentially expensive - you can spend 3 hours of code
writing to save 10 seconds of code execution.

Hadley

-- 
RStudio / Rice University
http://had.co.nz/


More information about the Rcpp-devel mailing list