Reputation: 6157
What does <bytecode: 0x02b59ae4>
in below code mean ?
> nchar
function (x, type = "chars", allowNA = FALSE, keepNA = FALSE)
.Internal(nchar(x, type, allowNA, keepNA))
<bytecode: 0x02b59ae4>
<environment: namespace:base>`
is it useful for anything ?
Upvotes: 4
Views: 1519
Reputation: 60492
The bytecode
statement indicates that the function has been byte compiled by the compiler
package. All base R functions are byte compiled. Byte compiled functions are almost always faster than the non-compiled version.
If a package has a ByteCompile: true
in its DESCRIPTION file, all functions in the package will be byte-compiled.
You can compile your own functions if you want:
f = function(x) x
f_cmp = compiler::cmpfun(f)
f
# function(x) x
f_cmp
# function(x) x
# <bytecode: 0x7f371a8>
Alternatively, you can set R_COMPILE_PKGS=3
in your .Renviron
and that will byte-compile package on installation. This assumes you are installing the package from source.
Upvotes: 11