[Rcpp-devel] [ANN] RcppAnnoy with templated Module use and Python re-use

Dirk Eddelbuettel edd at debian.org
Sun Nov 16 15:57:42 CET 2014


A new (and somewhat tiny) package is on CRAN and I just blogged / tweeted
about it, see eg http://dirk.eddelbuettel.com/blog/2014/11/16#rcppannoy_0.0.2
or http://dirk.eddelbuettel.com/code/rcpp.annoy.html

I mostly mention it here because of two aspects I enjoyed while writing the
package: 

i) Rcpp Modules for templated classes

Gregory Jefferis asked about this topic in a thread on this list back in
September, see http://thread.gmane.org/gmane.comp.lang.r.rcpp/7599 for the
thread.  After a few posts Romain reminded us all of the useful (albeit
un(der)documented RCPP_EXPOSED_CLASS_NODECL which is what I ended up using
here too.  Thanks to everybody who participated in that thread; we now have a
simple example package for it too.

ii) Interacting with Python

Annoy is a small C++ library which ships with a small Python module providing
access -- and we get the exact same functionality in R via Rcpp Modules. So
if you ever need to wrap something you have in C++ used by R, this may be a
nice stanza to go the other way.  From what I know about Python, this seems
like old-school packaging, ie no Cython or Theano or other fancypants (as
this is AFAIK used in production by Spotify -- with the usual restrictions on
older compilers and toolchains, ie Erik put a small ifdef in for a much older
Boost library). Just straight up C++ into Python, and now R.  We nicely reuse
the same mmap'ed index file, and of course get the same results in either
language. 

Cheers, Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list