From suharto_anggono at yahoo.com  Sun Apr 29 05:11:25 2018
From: suharto_anggono at yahoo.com (Suharto Anggono Suharto Anggono)
Date: Sun, 29 Apr 2018 03:11:25 +0000 (UTC)
Subject: [Rd] Result of 'seq' doesn't use compact internal representation
References: <1945318618.2079052.1524971485565.ref@mail.yahoo.com>
Message-ID: <1945318618.2079052.1524971485565@mail.yahoo.com>

> .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?

> 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



[Rd] Result of 'seq' doesn't use compact internal representation
Suharto Anggono Suharto Anggono