[Numpy-discussion] Numpy/Cython Google Summer of Code project idea

Christopher Barker Chris.Barker@noaa....
Fri Mar 7 11:50:24 CST 2008

Joris De Ridder wrote:
> Thanks. I've a few questions concerning the objections against ctypes.  

It's not so much an abjection (I think), but the fact that pyrex/Cython 
really are different beasts, with different goals.

 > For ctypes your extensions needs to be
> compiled as a shared library,

The compiling isn't the key issue -- you're right, that's not too big a 
deal, and Scons helps.

If your goal is primarily to wrap existing C code, then ctypes is a good 
option. But if you are trying to write new code as extension modules, 
then Cython helps with that a lot. You do need to "get" C, but you don't 
actually have to write functional stand-alone C code.

> neither pyrex nor ctypes seem to be particularly user- 
> friendly concerning Numpy ndarrays 

True, though it looks like one of the goals of Cython is to make it more 
user-friendly to numpy arrays -- I'm really looking forward to that.

I suppose an example might be in order here - does anyone have a small, 
but not trivial, example of an extension that could be done with both 
Ctypes and Cython that we could examine?

By the way, I know Greg Ewing was asked about better support for numpy 
arrays in Pyrex, and he said "I'm *definitely* not going to
re-implement C++ templates!" -- is there talk of creating a way to write 
extensions that could operate on numpy arrays of arbitrary type with Cython?


Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception


More information about the Numpy-discussion mailing list