[Rd] Understanding tracemem
mdowle at mdowle.plus.com
Thu Jul 12 18:54:39 CEST 2012
Hadley Wickham <hadley <at> rice.edu> writes:
> Why does x <- 5 create a copy
That assigns 5 not 5L. x is being coerced from integer to double.
x <- 5L doesn't copy.
> , when x (which should be
> extending a vector does not) ? I can understand that maybe x <- 5
> hasn't yet been optimised to not make a copy, but if that's the case
> then why doesn't x <- 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().
More information about the R-devel