-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Mon, Apr 28, 2008 at 08:57:52PM -0700, Alex Harford wrote: > On Mon, Apr 28, 2008 at 8:14 PM, Peter Todd wrote: > > > > Cython > > looks quite promising for this sort of stuff, essentially it is a > > dialect of Python that can compile directly to fast C code, while stil > > being able to easilly interface with regular Python. > > Wish I had time to have a look at the code. Way too busy right now > though. Just a suggestion, have you considered using swig to wrap C > libraries to be used by Python? I've found it to be extremely useful. I have looked at swig, and will likely end up using it indirectly in the form of wrappers to some geometry libraries. That said, Cython looks better for stuff I'm writing from scratch. For instance from this page: http://www.perrygeo.net/wordpress/?p=116 cdef extern from "math.h": float cosf(float theta) float sinf(float theta) float acosf(float theta) def great_circle(float lon1,float lat1,float lon2,float lat2): cdef float radius = 3956.0 cdef float pi = 3.14159265 cdef float x = pi/180.0 cdef float a,b,theta,c a = (90.0-lat1)*(x) b = (90.0-lat2)*(x) theta = (lon2-lon1)*(x) c = acosf((cosf(a)*cosf(b)) + (sinf(a)*sinf(b)*cosf(theta))) return radius*c Not bad 'eh? Yet, great_circle() is callable from Python, as a Python function. This gets compiled down to raw C using the Python C-Extension API, but in a *far* less verbose fashion. Numpy is reportedly rewriting a lot of it's code in Cython, and development on Cython itself, and Numpy for that matter, is sponsored by the people behind the SAGE Open Source Mathematics Software project. - -- htt://petertodd.org 'peter'[:-1]@petertodd.org -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFIFqIv3bMhDbI9xWQRApQiAJ9EiuubCXAh8LBNhhsKEXhmyxgBewCfZuPc vnW/fedkpxZtJi8qgMnN2SI= =6Qac -----END PGP SIGNATURE----- -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist