How to make best use of the byte compiler in R

[This article was first published on Revolutions, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Tomas Kalibera,  the newest member of the R Core Team, has been working for the last several years with fellow Core Team member Luke Tierney implementing R's byte-code compiler and interpreter. Byte-compiling R code often improves its speed of execution, and usually happens without you having to take any explicit action. R's base and recommended packages are compiled when R is installed, and your scripts and functions are automatically compiled “just-in-time” as you execute them. 

At the useR!2017 conference last month, Tomas Kalibera gave a very interesting talk: Taking Advantage of the Byte Compiler. In particular, he shows that not all R code is equivalent to the byte compiler. For example, the byte compiler has most impact on code that works with scalar arithmetic in tight loops. There's also some kinds of R code that takes a relatively long time to compile, which can swamp the performance benefits if the function is compiled at execution-time. (Package authors can avoid this for their users by declaring that their packages be compiled on install, by including Byte-Compile: yes in the DESCRIPTION file.) For package authors and R users that care about performance, you can find lots of tips like this in the talk embedded below.

For even more details on the implementation of the byte-compiler, take a look at the document A Byte Compiler for R by Luke Tierney.

To leave a comment for the author, please follow the link and comment on their blog: Revolutions. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)