[datatable-help] Copy on assign broken in some cases

Matthew Dowle mdowle at mdowle.plus.com
Sat Nov 12 03:07:29 CET 2011


mhwaliji wrote:
> 
> How about this - add a new argument to data.table(), say
> max.cols. max.cols defaults to a couple orders of magnitude
> above the initial number of columns.  data.table allocates enough
> memory for max.cols column pointers.  If you try to add more
> than max.cols columns, it is either an error, or it creates a copy
> and produces a warning.
> 


mdowle wrote:
> 
> Very nice idea. To over allocate by default so that := can add
> columns fully by reference most of the time seems good to me since
> there's a very low cost to over allocating the vector of column
> pointers. Create the (shallow copy) and issue a warning, I'm thinking, not
> error. The "max.cols" names seems a bit absolute, could it be
> "alloc.cols"?  We could have alloc(DT,2,ncol) or rowalloc(DT,n) and
> colalloc(DT,n), or realloc(...) so users can over alloc themselves before
> a loop
> that adds columns or inserts rows.  tables() could also report truenrow,
> and truencol as well as nrow and ncol.  What should alloc.cols be,
> by default? How about:  max(100,2*ncol)
> 


mhwaliji wrote:
> 
> Fine with me.
> 

Done, committed to v1.7.3 on R-Forge.

Matthew


--
View this message in context: http://r.789695.n4.nabble.com/Copy-on-assign-broken-in-some-cases-tp3945590p4033337.html
Sent from the datatable-help mailing list archive at Nabble.com.


More information about the datatable-help mailing list