[Rd] Fast way to call an R function from C++?

Iñaki Ucar |uc@r @end|ng |rom |edor@project@org
Wed Jun 19 12:43:20 CEST 2019


On Wed, 19 Jun 2019 at 07:42, King Jiefei <szwjf08 using gmail.com> wrote:
>
> Hello Kevin and Iñaki,
>
> Thanks for your quick responses. I sincerely appreciate them! I can see how complicated it is to interact with R in C. Iñaki's suggestion is very helpful, I saw there is a lot of performance gain by turning the flag on, but sadly the best performance it can offer still cannot beat R itself. It is interesting to see that C++ is worse than R in this special case despite there is a common belief that C++ code is the fast one... Anyway, thanks again for your suggestions and reference!

That is misleading. C++ code is faster, that's beyond doubt. But you
are not running C++ code here, you are running R code. So what is
faster, running R code or executing something that then runs R code?
Obviously the first thing is the baseline, and from there, it can only
get worse as you add more layers on top of it.

Iñaki



More information about the R-devel mailing list