• wheezy@lemmy.ml
    link
    fedilink
    arrow-up
    42
    arrow-down
    1
    ·
    edit-2
    5 hours ago

    I know people joke around about this a lot. But I was blown away by a recent switch to I did from using cv2 with python to using cv2 with C++.

    I had literally hundreds of thousands of images to analyze for a dataset. My python script would have taken 12 hours.

    I ported it to C++ and it literally destroyed it in 20 minutes.

    I’m sure I was doing something that really wasn’t optimized well for python. I know somewhere in the backend it probably was using a completely different library with multi thread optimization. Or maybe turbojpg is just garbage in python. I’m still not even sure what the bottleneck was. I don’t know enough to really explain why.

    But holy shit. I never had that much of a performance difference in such a simple task.

    Was very impressed.

    • bitwolf@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      4
      ·
      1 hour ago

      I had a similar experience processing PDFs of building plans. 4-8k PDFs, took 5-10minutes in Python.

      I ended up switching to node.js and it processed the same PDFs in 120 seconds.

      Over the years I only really find Python useful for interviewing and occasionally in ci pipelines.

    • jsomae@lemmy.ml
      link
      fedilink
      arrow-up
      21
      ·
      4 hours ago

      Exactly what this comic is saying. C++ can handle in 20 minutes what takes python 12 hours, but something gets destroyed.

      • wheezy@lemmy.ml
        link
        fedilink
        arrow-up
        7
        ·
        edit-2
        3 hours ago

        Was a personal project. But absolutely. Half my job is trying to explain why something is taking so long when in reality I actually it’s already done I just don’t want to do nothing for the next few days.

        Managers never really know. And other engineers don’t care. It’s all about balancing expectations.

    • bobbyfiend@lemmy.ml
      link
      fedilink
      arrow-up
      2
      arrow-down
      1
      ·
      5 hours ago

      Not having true vectorization and having to regularly code that into Python helps even the odds.

  • bobbyfiend@lemmy.ml
    link
    fedilink
    arrow-up
    12
    arrow-down
    1
    ·
    5 hours ago

    This has got to be the best, most legitimately funny programmer/computer joke I’ve seen in years.

  • qjkxbmwvz@startrek.website
    link
    fedilink
    arrow-up
    12
    ·
    7 hours ago

    It’s interesting that, with Python, the reference implementation is the implementation — yeah there’s Jython but really, Python means both the language and a particular interpreter.

    Many compiled languages aren’t this way at all — C compilers come from Intel, Microsoft, GNU, LLVM, among others. And even some scripting languages have this diversity — there are multiple JavaScript implementations, for example, and JS is…weird, yes, but afaik can be faster than Python in many cases.

    I don’t know what my point is exactly, but Python a) is sloooow, and b) doesn’t really have competition of interpreters. Which is interesting, at least, to me.

    • flubba86@lemmy.world
      link
      fedilink
      arrow-up
      7
      ·
      4 hours ago

      Pypy is often considered the “best” alternative Python implementation. In some cases it can be much faster. But it’s often one or two versions behind, and not 100% compatible, and of course it doesn’t work with native Cpython extensions.

  • lime!@feddit.nu
    link
    fedilink
    English
    arrow-up
    52
    arrow-down
    1
    ·
    edit-2
    10 hours ago

    alternative joke

    C++: “Hey, what’s your name?”
    Python: *grabs C++* “what is my name?”

      • lime!@feddit.nu
        link
        fedilink
        English
        arrow-up
        2
        ·
        1 hour ago

        one of python’s strong suits is it’s foreign function interface. it’s very easy to call code in other languages from python, which can speed execution up significantly

      • anomnom@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        10
        arrow-down
        1
        ·
        4 hours ago

        Pythons weak typing means it never knows what is what. It’s up to the programmer to not screw it up.