Thanks every body, I want to close the subject, but just a naive question: Does numpy use a* vectorization *for arrays? I mean when I add 2 arrays ( or in sum function) how it is done, in an other word b=np.arange(100); t=np.sum(b) is equivalent or not to s=0 for i in range(100): s +=b[i] thanks a lot
Le sam. 26 févr. 2022 à 06:44, Dan Stromberg <drsali...@gmail.com> a écrit : > > On Fri, Feb 25, 2022 at 8:12 AM BELAHCENE Abdelkader < > abdelkader.belahc...@enst.dz> wrote: > >> Hi, >> a lot of people think that C (or C++) is faster than python, yes I agree, >> but I think that's not the case with numpy, I believe numpy is faster than >> C, at least in some cases. >> > > This is all "last time I heard". > > numpy is written, in significant part, in Fortran. > > Fortran, especially for matrix math with variable dimensions, can be > faster than C. > > Fortran, (still last I heard) did not support pointers, which gives > Fortran compilers the chance to exploit a very nice class of optimizations > you can't use nearly as well in languages with pointers. > > I used to code C to be built with the "noalias" optimization, to get much > of the speed of Fortran in C. But it required using an error prone subset > of C without good error detection. > > > -- https://mail.python.org/mailman/listinfo/python-list