gilbo/cork — pull request #17 by stevedh (2014-11-17 18:13:59+00:00)
Title: Python Bindings for Cork

This is mostly to see if you're interested in supporting python bindings. I wrote some typemaps that do a pretty decent (zero-copy!) job of it if you use numpy matrices. There are test cases that verify we get the same result as calling the binary on the samples (they won't work though unless you patch initRand and just do an srand(0) there).

Before we would merge, I think there are a couple things we need to check ...
* I'm not sure how cork allocates memory, but python is probably going to call free() on the memory returned at some point. The references to the return arrays get stolen by numpy. This should be fine/desirable, provided we make sure that numpy is using the matching deallocator from cork and that we're not leaking memory. Otherwise we'll need a copy on the way back to python.
* I was able to get this to work on OSX 10.10, and Ubuntu 14.05 with clang++. However, the library isn't built with -fPIC, and so there could be problems if you use a different compiler.
* The setup.py isn't self contained now -- it doesn't call make to build the library. With some more fiddling, we could make this easier to distribute with pip.