[Numpy-discussion] State-of-the-art to use a C/C++ library from Python

Antoine Pitrou solipsis at pitrou.net
Wed Sep 7 09:35:39 EDT 2016


On Fri, 2 Sep 2016 02:16:35 -0700
Nathaniel Smith <njs at pobox.com> wrote:
> >
> > Depending on how minimal and universal you want to keep things, I use
> > the ctypes approach quite often, i.e. treat your numpy inputs an
> > outputs as arrays of doubles etc using the ndpointer(...) syntax. I
> > find it works well if you have a small number of well-defined
> > functions (not too many options) which are numerically very heavy.
> > With this approach I usually wrap each method in python to check the
> > inputs for contiguity, pass in the sizes etc. and allocate the numpy
> > array for the result.  
> 
> FWIW, the broader Python community seems to have largely deprecated
> ctypes in favor of cffi.

I'm not sure about "largely deprecated". For sure, that's the notion
spreaded by a number of people.

Regards

Antoine.





More information about the NumPy-Discussion mailing list