This is now resolved in R-devel and R_patched.

Best,

luke

On Sun, 29 Apr 2018, Luke Tierney wrote:

Thanks -- I'll commit a fix after some testing.

Best,

luke

On 04/29/2018 06:22 AM, Duncan Murdoch wrote:
On 28/04/2018 11:11 PM, Suharto Anggono Suharto Anggono via R-devel wrote:
.Internal(inspect(1:10))
@300e4e8 13 INTSXP g0c0 [NAM(3)]  1 : 10 (compact)
.Internal(inspect(seq(1,10)))
@3b6e1f8 13 INTSXP g0c4 [] (len=10, tl=0) 1,2,3,4,5,...
system.time(1:1e7)
    user  system elapsed
       0       0       0
system.time(seq(1,1e7))
    user  system elapsed
    0.05    0.00    0.04

It seems that result of function 'seq' doesn't use compact internal representation. However, looking at the code of function 'seq.default', seq(1,n) produces 1:n. What is going on?

It looks like it is related to using compiled or interpreted code:

 > library(gtools)
 > seq2 <- unByteCode(seq.default)
 > .Internal(inspect(seq.default(1,10)))
@7fa53847dcd8 13 INTSXP g0c4 [] (len=10, tl=0) 1,2,3,4,5,...
 > .Internal(inspect(seq2(1,10)))
@7fa537fa0bf0 13 INTSXP g0c0 [NAM(3)]  1 : 10 (compact)

Duncan Murdoch


h <- seq.default
environment(h) <- .GlobalEnv
library(compiler)
enableJIT(0)
[1] 3
.Internal(inspect(h(1,10)))
@375ade8 13 INTSXP g0c0 [NAM(3)]  1 : 10 (compact)

A non-byte-compiled version of function 'seq.default' can produce object that uses compact internal representation.


sessionInfo()
R version 3.5.0 (2018-04-23)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows XP (build 2600) Service Pack 3

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] compiler  stats     graphics  grDevices utils     datasets  methods
[8] base

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel



--
Luke Tierney
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
   Actuarial Science
241 Schaeffer Hall                  email:   luke-tier...@uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to