Tech Talk

Linux, Python, E51, Scripting…

From python to C(pp)

with 2 comments

A directed graph.

Image via Wikipedia

Yesterday was big disappointment. My python code was taking just too long to process a graph of about 30000 nodes and 80000 edges. Actually, it was taking more than an hour to just construct it. After that I have a bunch of algorithms to run on it. And this graph is generated from a sample graph of about 1024 nodes and edges. But in reality I need to run the whole thing against an initial graph of 20000 nodes. The whole thing just doesn’t sound to work. There are two possibilities: First is my code could be dirty; Or python does not do my kind of work very well. I can’t say anything about python until I have cleared my code to be the best. But I don’t have the time to invest here, since all this is just paths to my actual work, and my work is elsewhere!

So, the other choice is to code the whole thing in C/C++. Actually it should be C, because I am not a particular fan on C++. But given the time constraints, I just may have to go with C++. The reason is simple. I want something like STL to hasten my job and not worry about performance. I simply don’t see any such library for C. There are some ways to use STL with C, I guess. So, C++ it is. I should probably spend some time and write STL like library for C or at least spend some time to see if somebody is already doing the job. Anybody knows some good library for C, please leave a comment. Yeah, and don’t bother asking why I am not a fan of C++. I wouldn’t bother to reply.

Zemanta Pixie

Written by abiya

June 13, 2008 at 4:11 am

Posted in c, python, technical

Tagged with ,

2 Responses

Subscribe to comments with RSS.

  1. I think youve made the right choice. its been three years since i used STL (since first year in grad school) and my C expertise is hopeless anyway. if its just a one time run, it should not matter whether it takes 1 hr to run (python) or 40 mins(C). again i dont know what your context is.

    ramakrishnan

    June 17, 2008 at 2:33 pm

  2. @rama actually, the whole thing is a one time run and that is why we chose to use python in the first place. But during construction and verifying that your algorithm is right, you might want faster results! btw, the graphs are so large that even C segments with OutOfMemory on a 2G ram machine! We just need to do things in a phased manner and python will be back in action!!

    ingeneur

    June 17, 2008 at 11:50 pm


Leave a Reply