Re: [Rd] Understanding tracemem

From: Matthew Dowle <>
Date: Thu, 12 Jul 2012 16:54:39 +0000

Hadley Wickham <hadley <at>> writes:

> Why does x[5] <- 5 create a copy

That assigns 5 not 5L. x is being coerced from integer to double.

x[5] <- 5L doesn't copy.

> , when x[11] (which should be
> extending a vector does not) ? I can understand that maybe x[5] <- 5
> hasn't yet been optimised to not make a copy, but if that's the case
> then why doesn't x[11] <- 11 make one?

Extending a vector is creating a new (longer) vector and copying the old (shorter) one in. That's different to duplicate(). tracemem only reports calls to duplicate().

Matthew mailing list Received on Thu 12 Jul 2012 - 16:56:56 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 12 Jul 2012 - 17:30:32 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive