[Rcpp-devel] List of Lists to List of Vectors

Tim Keitt tkeitt at utexas.edu
Mon May 4 21:42:38 CEST 2015


On Mon, May 4, 2015 at 2:37 PM, Dirk Eddelbuettel <edd at debian.org> wrote:

>
> On 4 May 2015 at 14:23, Tim Keitt wrote:
> |
> |
> | On Sun, May 3, 2015 at 11:29 PM, Antonio Piccolboni <
> antonio at piccolboni.info>
> | wrote:
> |
> |     Check here  for something similar to Tim's solution that
> preallocates all
> |     vectors to avoid the costly push_back. Still needs the unlists in R,
> so
> |     it's expensive in that dimension, the number of lists in the output.
> |
> |
> | I may have a way around the unlist part; still needs testing.
>
> Keep us posted.
>
> | push_back is amortized constant so only a little costly.
>
> But going from std::list to SEXP is one full copy.  Not so bad in the grand
> scheme of things.
>

Copying is where all the costs accumulate for sure. I find it mostly
guesswork whether something copies or not with Rcpp data structures.

THK


>
> Dirk
>
> --
> http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>



-- 
http://www.keittlab.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20150504/35334535/attachment.html>


More information about the Rcpp-devel mailing list