Cython
- 2 minutes read - 276 wordsAfter I had finally convinced myself to get out of bed this morning to go to my ACMS seminar, I quickly checked my email and my heart sank a little. Today’s talk was on SAGE. Don’t have anything against SAGE, but I thought it was just a big pile of open source packages in a big, heavy install. Sorta cool, but worthless, in other words.
Turns out, I was pretty wrong about that. It is that, but it’s also 70k new lines of code that does a whole bunch of exciting stuff. Near the end of his talk, William Stein mentioned that they had created a new tool called Cython. (Well, extended Pyrex, but… whatever.)
Cython is pretty neat. It’s a compiler that takes Python code and outputs C code. This C code is in turn compiled by GCC into a shared library… which in turn can be accessed from standard python code. Which sounds like a lot of trouble for not much gain. Au contrair, amigo. Trivial changes from Python -> Cython give 10x improvements. Converting some Python lingos into slightly more C-like syntax gives 100x improvements. Even 1000x improvements are not unheard of. This is incredible stuff. It’s also really important to SAGE… it’s how they write in mostly python but maintain that speed.
Anyways, back to me. I’m pretty much a compiler dork, so this stuff gets me pretty excited. I went up and talked to him afterwards, and he told me that there’s money to be made with this stuff. Very, very exciting. I’m gonna start diving into it very soon, and I’m sure I’ll have more to say about it soon.