Python: The Ultimate Performance Benchmark Punchline
Description
This image uses the 'We are not the same' meme format, which features actor Giancarlo Esposito (as his character Gus Fring) adjusting his tie with a look of superiority. The top text, in a bold white font, reads, 'YOU OPTIMIZE CODE TO MAKE IT FAST'. The bottom text reads, 'I BENCHMARK IT AGAINST PYTHON'. The meme humorously contrasts two different approaches to performance. One developer engages in the complex and serious work of optimizing code for speed. The other, portrayed as smugly superior, takes a shortcut by benchmarking their code against Python, a language notoriously slower for many CPU-intensive tasks compared to compiled languages like C++ or Rust. The joke is that almost any compiled code will appear fast when compared to Python, making it a low and almost meaningless bar for proving performance, and thus not a real achievement
Comments
27Comment deleted
Benchmarking against Python is the performance equivalent of 'works on my machine' - technically true, but proves absolutely nothing to anyone who matters
Nice flex: your C++ loop is 300× faster than Python - too bad p99 latency is still owned by the network hops and the feature-flag service
After 20 years in the industry, you realize the real optimization was choosing Python in the first place - not for speed, but for the velocity of shipping features while your competitors are still debugging their segfaults and fighting with build systems
The real power move is benchmarking against Python 2.7 running on a Raspberry Pi Zero - suddenly your O(n³) algorithm looks like it's been touched by the hand of Knuth himself. Bonus points if you're comparing a compiled language with -O3 optimizations against an unoptimized Python script that imports pandas just to add two numbers. It's the performance engineering equivalent of winning a race against someone who's still tying their shoes, but hey, the charts look impressive in the architecture review
Why profile hotspots when Python's GIL turns every benchmark into a gold medal for 'not the slowest'?
If the perf KPI is “beats Python,” congratulations - you optimized the benchmark, not the algorithm; call me when it outruns CPython+NumPy on a cold cache with the same complexity
Benchmarking against CPython's single-threaded loop is the perf engineer's version of fixing a Sev-1 by changing the SLO: the graphs go green, the architecture stays slow
А потом такие шутники пишут на "быстрых" языках n^4 алгоритм для того, что нампай из коробки делает за n. Comment deleted
...but slower. Comment deleted
Use of right tools alone does not make the outcome right. (Applies to both compiled languages and numpy.) Comment deleted
use English please @SmirnGreg Comment deleted
Sorry, always forget for this chat 😢 -- Later, the same folks: develop n^4 algorithm on a "fast" language, where numpy has n out of the box Comment deleted
if I understand you correctly, then there's little difference between n^2 and n^4. I would say only e^n makes real difference Comment deleted
There is quite a difference. Of course, exponent is always worse. But there is a big difference between polynomes. Imagine, function calculates something based on immediate use input. Current scope is to display the user 1 week of data, and it takes 0.1s to process. Then, the product is going to update, and the time range increases to 1 month. Or 6 months. 1 month is 4 weeks, so n^2 will be 16 times slower — 1.6 second — barely tolerable. n^4 will be 256 times slower — 26 seconds(!!) — absolutely impossible. Comment deleted
or they make it even O(n), but still 2000 times slower than numpy. Comment deleted
remember, everything is O(1) if you just always check every possible option regardless Comment deleted
ну во-первых, как-то агрессивно, во-вторых - так для питона почти все либы ж и написаны на плюсах, разве нет? сам питон это чисто АПИшка к нему, если так можно выразиться Comment deleted
WRITE IN ENGLISH PLEASE Comment deleted
Didn't see you telling that to the first commentator here🤯Sorry Comment deleted
Somebody else told Comment deleted
That's what the very first comment is about: simply writing math in C does not make it really fast, unless you care about optimization. And that's why using finely tuned libraries even from interpreted languages like Python may be faster, not to say it's less prone to errors. Comment deleted
Hi everyone im just learning Python Comment deleted
I am a junior and not a Python dev, so want to ask: I heard that Python's main issue is performance, which is resolved with a help of a superset language Mojo. So, the meme means that a person benchmarks code against Python because Python is labeled the slowest nowadays, or it implies that Python has good benchmark rates? Thanks in advance. Comment deleted
first Comment deleted
Which doesn’t make it a bad language or whatever Comment deleted
Python is less forgiving. Compiled languages become more and more declarative as compilers become better: you write a loop with a condition inside, compiler resolves it to masking and vectorized operation, everyone is happy. Python is slower by itself because every Python object is a C structure with a lot of function calls on any event. On top of that, there is (normally) no compiler for Python which would optimize native Python code both algorithmically and reducing it to direct CPU instructions. There are solutions to make Python faster. Most notably, Python can link and execute compiled C code on runtime. This is how numpy is working. You create a numpy array, which from a python view is just a pointer to a normal C array with some metadata, and then numerics is outsourced to C solution or even MKL. Of course, it does not work if you do pythonic [np.sin(a) for a in arr] instead of np.sin(arr) — then python becomes extremely slow. Comment deleted
Thanks a ton! Comment deleted