Re:Another Book on Data Science – Learn R and Python in Para...
by claytonjy on Friday June 21, 2019 @11:07AM
(#20243150)
numpy is significantly faster and arguably more usable (e.g. broadcasting) than anything in R, and only recently has there been progress in more efficient matrix manipulation in R like rray[0], a wrapper for xtensor.
Re:Another Book on Data Science – Learn R and Python in Para...
by lottin on Friday June 21, 2019 @12:17PM
(#20243859)
As far as I can tell, R uses BLAS for matrix operations, and Python probably does the same, so in terms of efficiency I wouldn't expect a big difference between the two.
Re:Another Book on Data Science – Learn R and Python in Para...
by olooney on Friday June 21, 2019 @01:00PM
(#20244289)
Both R and numpy use BLAS, and if both are linked to the same library, say OpenBLAS or Intel MKL, then performance is in fact almost identical for expensive operations like matrix multiplication. (R also ships with its own internal BLAS implementation, which is reliable but not very fast, and I believe is still single threaded, so the first thing you should do if you are using R and care about performance is to swap it out.)
For more sophisticated linear algebra algorithm, such as SVD, both will use typically LAPACK, and again, both will exhibit essential identical performance.
There is one important difference though: when R is compiled for 64-bit machines, it can only use 64-bit floats! While numpy can support 32 and even (through software emulation) 16 bit floats. This can halve memory usage, which in turn halves cache misses, which results in a significant speed up in cases where 64-bits of precision is not needed.
Re:Another Book on Data Science – Learn R and Python in Para...
by wjn0 on Friday June 21, 2019 @06:10PM
(#20246687)
This is really interesting! I had always just claimed that Python was faster (see the benchmark I linked above [1]) based on personal experience. I wonder if this internal implementation has something to do with it...
How so?