From: Jeff W. <js...@fa...> - 2003-05-12 14:32:12
|
On Mon, 12 May 2003, Schnizer Pierre wrote: > > > Dear Mr Whitaker, > > | I just discovered that the ctypes module > | (http://starship.python.net/crew/theller/ctypes.html) makes it quite > | easy > | to access gsl library functions in python. You can do it in pure > | python, > | without any C code. > > Thank you for your information. I have seen this module when I was searching > for a tool providing > interconnection between C and Python. Having used f2py a lot, swig seemed to > fit very nicely. > I was not aware that ctypes had a nice callback implementation. Yes, it is quite easy. I was going to give a try with fortran shared libs, but haven't got around to it yet. > > Do you have any experience concerning the ctypes performance? Using swig I > can fine tune the wrapper to my needs and make a tradeoff between size and > speed. > Apart from that I can control the error exceptions generated internally. > These were my reasons to > use swig. > I've never tried swig, so I can't comment on the relative speed (or exception handling). There is also pyrex, which will automagically generate the c interface code from pseudo-python code (http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/). It does have very general exception handling. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/CDC1 FAX : (303)497-6449 325 Broadway Web : http://www.cdc.noaa.gov/~jsw Boulder, CO, USA 80305-3328 Office: Skaggs Research Cntr 1D-124 |