Using D and std.ndslice as a Numpy Replacement
jackstouffer.com
Using D and std.ndslice as a Numpy Replacement
1–10 of 59 posts
Re: Using D and std.ndslice as a Numpy Replacement
#2Re: Using D and std.ndslice as a Numpy Replacement
#3Use numba to compile python loops or array expressions to fast llvm, and problem solved. I'm sticking with python.
Re: Using D and std.ndslice as a Numpy Replacement
#4I tried the Armadillo C++ library a while ago (http://arma.sourceforge.net/). The speed up and time spend learning the syntax didn't seem worth it.
Re: Using D and std.ndslice as a Numpy Replacement
#5Am I correct in thinking that this is only reasonable if you're already using D? The switching cost seems too high if you're python everything. I tried the Armadillo C++ library a while ago ( http://arma.sourceforge.net/ ). The speed up and time spend learning the syntax didn't seem worth it.
why you should consider D for your next numerical project.Re: Using D and std.ndslice as a Numpy Replacement
#6Use numba to compile python loops or array expressions to fast llvm, and problem solved. I'm sticking with python.
Considering that in the benchmarked example, only one like of Numpy code was used which already uses compiled C, I have a hard time believing that that would catch up to using all compiled code.
Re: Using D and std.ndslice as a Numpy Replacement
#7Earlier quoted context omitted.
Considering that in the benchmarked example, only one like of Numpy code was used which already uses compiled C, I have a hard time believing that that would catch up to using all compiled code.
Numbs compiles entire functions on and allows array expressions with allocation and loop fusion. I don't see the problem
Re: Using D and std.ndslice as a Numpy Replacement
#8Because I use almost all of these every single day (I don't do multidimensional images or b-splines much at all). Are those all in standard libraries, fully documented, backed by 60 year old, fully debugge code (LAPACK, etc), that I reliably email to anyone across the world and they can immediately run and modify my code because it is such a standard? I honestly don't know, but I'm guessing not.
I use Python/Numpy/Scipy/Pandas/Matplotlib because everyone else in the world knows and uses them; they are a standard. Yes, my np.mean() might be slower than your map(). I almost always don't care. That misses the forest for the trees.
The article might be a good argument for why library writers might consider building out D's standard library to support numerical computation, I dunno. But no one is going to use D for serious number crunching without that infrastructure in place. People moved from Fortran and Matlab to Python not because it is fast, but for the environment. These language tricks are cute and all (I like D well enough, don't get me wrong), but it ain't why we are using Python.
At this point, if I were to switch languages to something without a lot of adoption I'd lean towards Julia. It also have a modern language design, but it is written from the ground up for numerical computation. I can't think of any reason I'd ever reach for D.
Re: Using D and std.ndslice as a Numpy Replacement
#9Earlier quoted context omitted.
Numbs compiles entire functions on and allows array expressions with allocation and loop fusion. I don't see the problem
The benchmarked code is ALREADY a comiled C function called from Python and it still lost.
also have the option of devecting to loops.
both of which are generally faster than vectorized jumpy code.
Re: Using D and std.ndslice as a Numpy Replacement
#10Why do I say this? Because inlining the python function to
means = numpy.mean(numpy.arange(100000).reshape((100, 1000)), axis=0)
from the original example in the article cut the benchmark time in down from around 215us to 205 us in my testing. That was done by removing a single python bytecode instruction.
Its quite likely that the D numerical code is actually slower than the LAPACK based python numerical code, but you're hiding this in the constant time overhead of a few python function calls.