C is it always faster than nump?

Chris Angelico rosuav at gmail.com
Fri Feb 25 18:02:16 EST 2022


On Sat, 26 Feb 2022 at 09:58, Richard Damon <Richard at damon-family.org> wrote:
>
> On 2/25/22 2:47 PM, Chris Angelico wrote:
> > On Sat, 26 Feb 2022 at 05:49, Richard Damon <Richard at damon-family.org> wrote:
> >> On 2/25/22 4:12 AM, BELAHCENE Abdelkader 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.
> >>>
> >> My understanding is that numpy is written in C, so for it to be faster
> >> than C, you are saying that C is faster that C.
> > Fortran actually, but ultimately, they both get compiled to machine code.
>
> Looking at the Github repo I see:
>
> Languages:
> Python.  62.5%
> C           35.3%
> C++.       1.0%
> Cython.   0.9%
> Shell.       0.2%
> Fortran.   0.1%
>
> So there is a bit of Fortan in there, but it looks like most of the
> heavy lifting is in C.
>
> My guess is the Fortran is likely some hooks to add Fortran modules into
> the program with numpy.
>

GitHub's analysis isn't always very meaningful. I think it's pretty
clear that Numpy isn't implemented in Python :) In any case, point is
that the implementation language is mostly irrelevant.

ChrisA


More information about the Python-list mailing list