Re: [Rcpp-devel] Making objects in the C++ "side" persistent
On 20 March 2014 at 20:03, Romain François wrote: | Creating a package does not give you persistence of external pointers across sessions. I didn't claim it did. AFAICR nothing simple achieves that. Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Re: [Rcpp-devel] Making objects in the C++ "side" persistent
Creating a package does not give you persistence of external pointers across sessions. Le 20 mars 2014 à 19:52, Dirk Eddelbuettel a écrit : > > On 20 March 2014 at 12:40, Jiqiang Guo wrote: > | RStan doesn't do anything to persist any c++ object. What's done is to save > | the binary file created using package inline in an R object so it can be > reused > | without recompiling c++ code. So what is in cxxfunplus might not be > related. > > Thanks for the clarification. > > My recommendation is usually to just create a package. We know that works. > > Dirk > > -- > Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Re: [Rcpp-devel] Making objects in the C++ "side" persistent
On 20 March 2014 at 12:40, Jiqiang Guo wrote: | RStan doesn't do anything to persist any c++ object. What's done is to save | the binary file created using package inline in an R object so it can be reused | without recompiling c++ code. So what is in cxxfunplus might not be related. Thanks for the clarification. My recommendation is usually to just create a package. We know that works. Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Re: [Rcpp-devel] Making objects in the C++ "side" persistent
RStan doesn't do anything to persist any c++ object. What's done is to save the binary file created using package inline in an R object so it can be reused without recompiling c++ code. So what is in cxxfunplus might not be related. Jiqiang On Mar 20, 2014 11:53 AM, "Dirk Eddelbuettel" wrote: > > On 20 March 2014 at 18:39, F.Tusell wrote: > | I have been reading "Exposing C++ functions and classes with Rcpp > | modules" and find the idea interesting. However, I read in Section 5 > | that objects created > | using an external pointer are not persistent from session to session. > > Yes. The memory behind that pointer is not guaranteed... > > | For my purposes, I think I could use S4 objects that make C++ copies of > | themselves at creation time, accessible via an external pointer. All > | methods would then make use of the C++ copies for speed, and at the end > | of the session the S4 copies that live in the R side would be saved. > | > | I am thinking of writing code which at the start of a session checks all > | (S4) objects in the workspace and recreate the C++ copies. Is this the > | way to go? Has someone with a similar problem devised an alternative > | solution? If anyone can offer some hints (or better yet, point to some > | package that I can use for inspiration) I would be grateful. > > The Stan folks also did something about this in an extension / rework of > cxxfunction in inline -- see their package cxxfunplus on CRAN. (Which I > haven't used so I can't help with details -- but it help you or point you > the > right way.) > > Dirk > > -- > Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com > ___ > Rcpp-devel mailing list > Rcpp-devel@lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel > ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Re: [Rcpp-devel] Making objects in the C++ "side" persistent
On 20 March 2014 at 18:39, F.Tusell wrote: | I have been reading "Exposing C++ functions and classes with Rcpp | modules" and find the idea interesting. However, I read in Section 5 | that objects created | using an external pointer are not persistent from session to session. Yes. The memory behind that pointer is not guaranteed... | For my purposes, I think I could use S4 objects that make C++ copies of | themselves at creation time, accessible via an external pointer. All | methods would then make use of the C++ copies for speed, and at the end | of the session the S4 copies that live in the R side would be saved. | | I am thinking of writing code which at the start of a session checks all | (S4) objects in the workspace and recreate the C++ copies. Is this the | way to go? Has someone with a similar problem devised an alternative | solution? If anyone can offer some hints (or better yet, point to some | package that I can use for inspiration) I would be grateful. The Stan folks also did something about this in an extension / rework of cxxfunction in inline -- see their package cxxfunplus on CRAN. (Which I haven't used so I can't help with details -- but it help you or point you the right way.) Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Re: [Rcpp-devel] Making objects in the C++ "side" persistent
Hello Fernando, For sure there will be better ideas, but sometimes I use serialized protocol buffers (RProtoBuf) for persistence, or even to treat data structures (or "classes") between R, C++, python or even C#. You can store serialized protobuf on the file system or using databases (sql or not). But for sure there are better ideas. Kind regards David Ibarra Gómez -Mensaje original- De: rcpp-devel-boun...@lists.r-forge.r-project.org [mailto:rcpp-devel-boun...@lists.r-forge.r-project.org] En nombre de F.Tusell Enviado el: jueves, 20 de marzo de 2014 18:40 Para: rcpp-devel@lists.r-forge.r-project.org Asunto: [Rcpp-devel] Making objects in the C++ "side" persistent I have been reading "Exposing C++ functions and classes with Rcpp modules" and find the idea interesting. However, I read in Section 5 that objects created using an external pointer are not persistent from session to session. For my purposes, I think I could use S4 objects that make C++ copies of themselves at creation time, accessible via an external pointer. All methods would then make use of the C++ copies for speed, and at the end of the session the S4 copies that live in the R side would be saved. I am thinking of writing code which at the start of a session checks all (S4) objects in the workspace and recreate the C++ copies. Is this the way to go? Has someone with a similar problem devised an alternative solution? If anyone can offer some hints (or better yet, point to some package that I can use for inspiration) I would be grateful. Best, F.Tusell ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel Disclaimer: http://disclaimer.aqualogy.net/ ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
[Rcpp-devel] Making objects in the C++ "side" persistent
I have been reading "Exposing C++ functions and classes with Rcpp modules" and find the idea interesting. However, I read in Section 5 that objects created using an external pointer are not persistent from session to session. For my purposes, I think I could use S4 objects that make C++ copies of themselves at creation time, accessible via an external pointer. All methods would then make use of the C++ copies for speed, and at the end of the session the S4 copies that live in the R side would be saved. I am thinking of writing code which at the start of a session checks all (S4) objects in the workspace and recreate the C++ copies. Is this the way to go? Has someone with a similar problem devised an alternative solution? If anyone can offer some hints (or better yet, point to some package that I can use for inspiration) I would be grateful. Best, F.Tusell ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel