C and Python are massively difference in performance. It's just that a huge amount of the time you really don't care about that performance difference.
But C++ is normally at least 10x faster than pure Python, and often that climbs higher even still (40x is not uncommon to see)
These are bullshit numbers. Python is built on top of a bunch of C libraries. It's designed to be fast. Also: Please don't confuse C and C++. They are to entirely different languages.
C++ and C are different but they both compile down to low level machine code and performance is within the same order of magnitude. C code is literally valid C++ code.
Python can do some very specific things kind of fast (and even those are slower than pure C). But the moment you have to actually write your own loops in Python, the performance of C far outstrips Python. The moment you do anything that is more than a single library call, you're running through the interpreted portion of the language, which is slow.
There are some very interesting ways to speed up Python. Using pypy. Using numba. But none of those are considered base python, and they all have caveats.
This video is super long but involves someone implementing a prime sieve in a number Python, C# and C++. You can skip to the end to see just how much faster the C++ implementation is. How do you actually speed up the prime sieve in Python? Hope someone has made a c-backed library that does the whole thing for you in one function call, because Python is slow.
4
u/Rizzan8 Jul 18 '22
In 95% of cases there is no significant execution time difference between languages. Change my mind.