On 2/14/10 7:57 AM, Nathaniel Smith wrote: > On Sat, Feb 13, 2010 at 9:55 PM, Laurent Gautier<lgaut...@gmail.com> wrote: >> Hi, >> >> rpy2-2.1.x will be dropping the "__array_struct__" way to export array >> information from R arrays to numpy arrays, and use instead the new >> buffer protocol in Python. >> >> This likely means that all numpy-related features in rpy2 will only be >> supported with Python>= 2.6 and numpy>= 1.3, but this also means that >> wizardry like "views" on vectors and arrays (that is an object is a >> "view" on larger array or vector, without a copy of the subset of data >> made) is getting possible. > > No objection to this, but views work just fine with the old > __array_struct__ way too, so I find your description confusing :-).
__array_struct__ is currently used to inform numpy about the structure of a given R vector/array (that is length, type, number of dimensions, etc...). This is going away by having R vectors/arrays exposed through rpy2 implement the buffer protocol. Recent numpy version know how to find the information they need (and used to obtain through __array_struct__ there). [There is certainly the possibility to leave __array_struct__ as an unsupported deprecated feature if someone requests it]. > Can you elaborate on what cool new features we'll see as a result of > this? By exporting the buffer protocol, all Python tools that make use of (so obviously numpy among them) will be able to access efficiently the data in R vectors/arrays. In other terms, that means that C-level code can be implemented to do perform operation on either array.array, numpy.ndarray, rpy2.rinterface.SexpVector (and by inheritance rpy2.robjects.IntVector, rpy2.robjects.FloatVector, ...). For example, python-opencl is able to create memory buffers on the (graphical) device from numpy arrays, or from any other object implementing the buffer protocol. This means being able to inter-exchange array, numpy, rpy2, or anything else implementing the buffer protocol without having formal dependencies between packages. The design decision to have rpy2 not requiring numpy (and is not importing it by default) is not foreign to that (the buffer protocol was still in its late development stages when I started on rpy2). Also, the memory views (new in Python 3) provide an API to create vector/arrays that are "views" on an underlying larger object without copying them. Nothing specific to rpy2, but that means that rpy2 can jump on that bandwagon as well. L. > -- Nathaniel > > ------------------------------------------------------------------------------ > SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, > Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW > http://p.sf.net/sfu/solaris-dev2dev > _______________________________________________ > rpy-list mailing list > rpy-list@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rpy-list ------------------------------------------------------------------------------ SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev _______________________________________________ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list