I might have spoken a bit too...excitedly at the Clawpack dev meeting last Monday about my progress with using Cython in the next version of Clawpack and as a result I got a few confused looks. :) My fault for not explaining the vision well. So just to be clear, Cython is a programming language built on top of Python that makes it easy to use and write fast C code with which Python functions and classes can interact. Anyway, right now I'm using Cython to come up with ways to allow users to provide their own solver routines, such as rp, src, step, etc., via a nice Python interface.
So I was looking deeper into how Cython turns a Cython source file (.pyx, .pxd) into a C file and then into a compiled Python module. Essentially, Cython is a tool built around the Python package, distutils. distutils is a module for importing specially-formatted C / C++ code. Cython makes is easier to write this code without having think to hard about the Python API.
First the user writes some C / C++ code using all sorts of pre-defined, Python interoperable structs and classes and such. That is, the user needs to conform to the Python C API, via#include "Python.h", and write the functions and operations such that they can properly interact with Python objects. Poke around this documentation and you'll see what I mean.
Now, you can feed that file into the usual setup() function from distutils. See the Cython documentation for more information on how to do that.
11 May 2009
03 May 2009
Chilling on a Couch
I was taking a walk, talking on the phone with an old high school friend when I found a couch sitting on the island in the middle of the roundabout next to my apartment!
[caption id="attachment_472" align="aligncenter" width="300" caption="A couch in the middle of the street!"]
[/caption]
It was such a nice day outside and it's not often that you get to sit outside on something comfortable. (It's usually some plastic fold-out or itchy wicker something.) So I continued our conversation on the couch.
[caption id="attachment_473" align="aligncenter" width="300" caption="Myself sitting upon said street couch."]
[/caption]
When we were done chatting I hung up and decided to hang out a little bit more. Again, it was such a pretty day! So I sat for thirty more minutes admiring the beautiful view.
I hope that couch stays for a while...
[PS: Just for comparison, here's an aerial shot. Also, a shot from Google's Street View. It appears they didn't have as nice of a day!]
[caption id="attachment_472" align="aligncenter" width="300" caption="A couch in the middle of the street!"]
[/caption]It was such a nice day outside and it's not often that you get to sit outside on something comfortable. (It's usually some plastic fold-out or itchy wicker something.) So I continued our conversation on the couch.
[caption id="attachment_473" align="aligncenter" width="300" caption="Myself sitting upon said street couch."]
[/caption]When we were done chatting I hung up and decided to hang out a little bit more. Again, it was such a pretty day! So I sat for thirty more minutes admiring the beautiful view.
I hope that couch stays for a while...
[PS: Just for comparison, here's an aerial shot. Also, a shot from Google's Street View. It appears they didn't have as nice of a day!]
Subscribe to:
Posts (Atom)
