igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] R versus Python


From: Steve Lianoglou
Subject: Re: [igraph] R versus Python
Date: Fri, 2 Dec 2011 09:46:16 -0500

Hi,


On Fri, Dec 2, 2011 at 4:33 AM, Thomas <address@hidden> wrote:
> I am stuck in Circle 3 of The R Inferno
> (http://www.burns-stat.com/pages/Tutor/R_inferno.pdf) which means my
> programs are running **slow** because of failing to vectorize. Every program
> I write seems to have two or three nested for loops.
>
> Anyway, I'm thinking of switching to Python and would be interested in
> hearing from anyone with an opinion on this. The alternative is to write
> vectorised functions in R and use those (there are no standard functions
> available for a lot of what I am doing - growing and manipulating graphs),
> but as far as I understand it, if I write those in R it won't have any
> impact on speed, in fact it will slow everything down even more. The only
> way to get this working faster would be to write the function in C. But then
> if I'm writing C, why not do it all in C? But then I want to use some igraph
> functions and I don't have C code for those etc etc. So I'm going around and
> around on this one.

One thing you might consider is to use a combination of the Rcpp and
inline packages to help make writing your "hot" code (the nested for
loops) using C(++) much easier.

`inline` lets you write the body of a C(++) function into a string in
R then compiles the function for you on the fly, which then allows you
to make R calls against it .. you won't have to go through the
rigamarole of compiling a library and linking against it.

> Seems like Python might not object to nested for, plus it has the igraph
> routines available.

Even though I know (for the most part) Python for loops are (quite(?))
a bit more zippy than R, I think any interpreted language will
(ultimately) protest to for loops.

As suggested by Minh, though, if you switch to Python, you can likely
use cython to help these pain points as well.

HTH,
-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact



reply via email to

[Prev in Thread] Current Thread [Next in Thread]