Thursday, July 15, 2010

RPy2 and PyCapsules

PyCapsules were one of the new features in Python 3 from which RPy2 was supposed to benefit. But it seems that they don't do exactly what I thought they do. They're a way of wrapping functions rather than objects so that they can be accessed by other modules. More specifically, it's supposed to be a portable (i. e. independent of symbol visibility between shared libraries) way of exposing C API to other C modules.
RPy2 doesn't expose any custom APIs to other modules, so there's seemingly no use for PyCapsules. Thus, Laurent (my mentor) and I decided not to include this feature in the project.

PyCapsules are described in section 1.12 of Extending Python:
http://docs.python.org/py3k/extending/extending.html#providing-a-c-api-for-an-extension-module
(in hindsight even the title is a bit of a giveaway: "Providing a C API for an Extension Module").

Tuesday, July 6, 2010

Things are working out

So here's a first usable version of RPy2:

Adapting the code to API changes went mostly smoothly, the tricky part was getting rid of leaks which I introduced while trying to get strings to work. It matches *all* functionality of RPy2 for Python 2.x and passes all unit tests (apart from those related to NumPy -- which doesn't work with Py3 yet). So RPy2 could well be the first numerical package ported to Python 3 ;)

Starting off

Hello and welcome,

My name is Greg Slodkowicz and this is my blog documenting progress in my Google Summer of Code project, "Porting RPy2 to Python 3."

Here is a short description of the project:

RPy2 is an interface between Python and the statistical package R. This project aims to port existing functionality of RPy2 to Python 3 as well as to improve integration by taking advantage of Python 3's features. It will be completed in three stages: porting RPy2's existing functionality, integrating new features of Python and its C API (MemoryViews, PyCapsules, ordered dictionaries) and lastly implementing an R graphical device which would be able to interface with Matplotlib.

The code is hosted on bitbucket (as is the original RPy2 project):