[Pyrex] Pyrex versus ctypes

David McNab david at rebirthing.co.nz
Fri Jun 11 00:01:01 CEST 2004


Hi,

After a year or so's hacking with Pyrex, I've come across the 'ctypes' 
package (http://starship.python.net/crew/theller/ctypes/).

ctypes allows the calling of C functions from *pure-python* code, 
without requiring the generation/compilation of a C wrapper module.

Pure python code using ctypes can even receive callbacks from C funcs, 
and manipulate C data structures, pretty much most of what one would 
need for interfacing with C.

All this feels too good to be true.

Can anyone offer some thoughts on the ideal demarcation lines between 
Pyrex and ctypes, and some thoughts on pros and cons, and which 
situations indicate Pyrex over ctypes and vice versa?

For instance, how severe are ctypes' overheads with constructing the C 
call frame, and rendering the return back to python?

-- 
Cheers
David




More information about the Pyrex mailing list