by harikb · 4y ago · 0 comments
> Python is two Orders of Magnitude (100x) slower than C. Suddenly, your $3,000 MacBook Pro barely beats an early-1990s-era 386DX computer.
Right under Java logo
> It is not just 60-frames-per-second games that long for high performance. Any CPU-bound or repeated process also requires it
You can't make typical Python programs two orders of magnitude faster by rewriting them in C, but that's because those use many bits that are already implemented in C (data structure implementations, regex engine, I/O, databases etc.).
If however you would rewrite those bits in Python, which is what OP said ("that Python is now the only legal programming language in the world to code with"), things would become two orders of magnitude slower (when using the current CPython implementation to run the Python program)! A program doing low-level work (e.g. a B-tree implementation) is that much faster when written in C over Python (if you don't cheat and write bits of your Python program in C), assuming that the C program does take advantage of the optimizations that you can do (and typically do) in C. It might be more like a factor of 60, but on a logarithmic scale that's much closer to two magnitudes than one.
This is assuming CPython, not PyPy or one of the subset-of-Python compilers that work more like C.
PS. OTOH, I think a 386DX is more like 1/1000 of a modern CPU's speed (maybe 1/10000 if counting multiple cores and SIMD).
> In general, the garbage collector is an inefficient beast.
The article has a tongue-in-cheek style, does the author really need to link to Benchmarks Game and CPU benchmarks?? Modern systems are way more than 100x faster than 386DX anyway.
I did search for benchmark comparisons and bumped into one that had 2 orders of magnitude difference.
But naturally, isolated benchmarks can't encapsulate the whole picture because there's a world of difference between testing how fast a loop runs and performance in production.