Are the functions 'R_Unserialize' and 'R_InitFileInPStream' allowed to be used in R packages? I guess I'm just not clear on the implications of this comment in 'Rinternals.h': /* The connection interface is not yet available to packages. To allow limited use of connection pointers this defines the opaque pointer type. */ I have a function in the 'filehash' package that unserializes a bunch of objects from a file and it seems to run much faster in C than in R. But I don't want to release something that uses a non-public function/interface. Thanks, -roger -- Roger D. Peng | http://www.biostat.jhsph.edu/~rpeng/
Henrik Bengtsson
2008-Jul-31 14:53 UTC
[Rd] C versions of serialize/unserialize in packages
Hi, On Thu, Jul 31, 2008 at 6:35 AM, Roger D. Peng <rpeng at jhsph.edu> wrote:> Are the functions 'R_Unserialize' and 'R_InitFileInPStream' allowed to > be used in R packages? I guess I'm just not clear on the implications > of this comment in 'Rinternals.h': > > /* The connection interface is not yet available to packages. To > allow limited use of connection pointers this defines the opaque > pointer type. */ > > I have a function in the 'filehash' package that unserializes a bunch > of objects from a file and it seems to run much faster in C than in R. > But I don't want to release something that uses a non-public > function/interface.You say "much faster". Could this be related to what I recently observed: July 24, 2008 thread '[Rd] serialize() to via temporary file is heaps faster than doing it directly (on Windows)' [ https://stat.ethz.ch/pipermail/r-devel/2008-July/050256.html ]. My $0.02 /Henrik> > Thanks, > -roger > -- > Roger D. Peng | http://www.biostat.jhsph.edu/~rpeng/ > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >
Prof Brian Ripley
2008-Jul-31 15:43 UTC
[Rd] C versions of serialize/unserialize in packages
On Thu, 31 Jul 2008, Roger D. Peng wrote:> Are the functions 'R_Unserialize' and 'R_InitFileInPStream' allowed to > be used in R packages? I guess I'm just not clear on the implications > of this comment in 'Rinternals.h': > > /* The connection interface is not yet available to packages. To > allow limited use of connection pointers this defines the opaque > pointer type. */It applies to R_InitFile(In|Out)PStream only, and is conditionalized by NEED_CONNECTION_PSTREAMS. You can't create a Rconnection pointer in your own C code in a public way. (The 'yet' has been there for nearly 7 years.) So what you are asking about is outside the conditional for that comment.> I have a function in the 'filehash' package that unserializes a bunch > of objects from a file and it seems to run much faster in C than in R. > But I don't want to release something that uses a non-public > function/interface. > > Thanks, > -roger > -- > Roger D. Peng | http://www.biostat.jhsph.edu/~rpeng/ > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595