From luke-tierney at uiowa.edu  Sun Apr 29 14:46:40 2018
From: luke-tierney at uiowa.edu (Luke Tierney)
Date: Sun, 29 Apr 2018 07:46:40 -0500
Subject: [Rd] 
 Result of 'seq' doesn't use compact internal representation
In-Reply-To: <9aaa8065-8fc4-ad16-1c56-e673dfd7e1c5@gmail.com>
References: <1945318618.2079052.1524971485565.ref@mail.yahoo.com>
 <1945318618.2079052.1524971485565@mail.yahoo.com>
 <9aaa8065-8fc4-ad16-1c56-e673dfd7e1c5@gmail.com>
Message-ID: <74699be7-4877-a233-78eb-1c8f6d58b149@uiowa.edu>

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 at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
> 
> ______________________________________________
> R-devel at 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-tierney at uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu



[Rd] Result of 'seq' doesn't use compact internal representation
Luke Tierney