3
$\begingroup$

I think there are numerous posts regarding which one to use: R or Python. However, I'm curious about how their architecture differences yield differences in speed performance, not which one to use.

This blog post performs a small test between R and python to show that the (optimized) python code was 2x faster than R code.* And I've read in this post that R tends to put everything in memory, which is why computations on large datasets is generally slow.

But what makes python's low level memory management so much different than R, which helps it yield these benchmarks?

*Though python was 2x faster in this test than R, I'm not saying that python is generally 2x faster than R.

$\endgroup$
  • $\begingroup$ Include in your comparison Revolution R, which is an optimized proprietary version of R with some libraries released for free. $\endgroup$ – Anton Tarasenko Jun 21 '15 at 18:58
1
$\begingroup$

It depends on the usage of various packages (Numpy/Scipy etc), which are written in C and be incredibly fast also Python can be complied using JIT. Here is an excellent comparison between R and Python : https://learnanalyticshere.wordpress.com/2015/05/14/clash-of-the-titans-r-vs-python/

| improve this answer | |
$\endgroup$
0
$\begingroup$

R's performance depends incredibly on how you write it. For example, you mostly should never use for loops in R - they're horribly slow because they execute a function call with every iteration. (One should vectorize and use the apply family of functions instead. Weird, I know..) Vectorization is king in R if you want fast code. Assuming you vectorize both your R and Python code (and other factors), you should probably get the same order of magnitude in speed. For data larger than memory (you can specify the limit), R starts to become a bad choice. I don't know much about python's internals, so I can't speak on that.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.