Skip to content
DevMeme
4936 of 7590
Performance Post #5403 · source on Telegram

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

27
Anonymous ★ Top Pick Benchmarking against Python is the performance equivalent of 'works on my machine' - technically true, but proves absolutely nothing to anyone who matters
  1. Anonymous ★ Top Pick

    Benchmarking against Python is the performance equivalent of 'works on my machine' - technically true, but proves absolutely nothing to anyone who matters

  2. Anonymous

    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

  3. Anonymous

    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

  4. Anonymous

    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

  5. Anonymous

    Why profile hotspots when Python's GIL turns every benchmark into a gold medal for 'not the slowest'?

  6. Anonymous

    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

  7. Anonymous

    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

  8. @SmirnGreg 2y

    А потом такие шутники пишут на "быстрых" языках n^4 алгоритм для того, что нампай из коробки делает за n.

    1. @Araalith 2y

      ...but slower.

    2. @SamsonovAnton 2y

      Use of right tools alone does not make the outcome right. (Applies to both compiled languages and numpy.)

    3. @RiedleroD 2y

      use English please @SmirnGreg

      1. @SmirnGreg 2y

        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

        1. @azizhakberdiev 2y

          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

          1. @SmirnGreg 2y

            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.

    4. @deadgnom32 2y

      or they make it even O(n), but still 2000 times slower than numpy.

      1. @RiedleroD 2y

        remember, everything is O(1) if you just always check every possible option regardless

    5. Алексей 2y

      ну во-первых, как-то агрессивно, во-вторых - так для питона почти все либы ж и написаны на плюсах, разве нет? сам питон это чисто АПИшка к нему, если так можно выразиться

      1. @mekosko 2y

        WRITE IN ENGLISH PLEASE

        1. Алексей 2y

          Didn't see you telling that to the first commentator here🤯Sorry

          1. @mekosko 2y

            Somebody else told

      2. @SamsonovAnton 2y

        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.

  9. Deleted Account 2y

    Hi everyone im just learning Python

  10. @develdd 2y

    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.

    1. @callofvoid0 2y

      first

    2. dev_meme 2y

      Which doesn’t make it a bad language or whatever

    3. @SmirnGreg 2y

      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.

      1. @develdd 2y

        Thanks a ton!

Use J and K for navigation