The Bitter Truth: Python 3.11 vs. Cython vs. C++ Performance for Simulations

  • Side note: Can somebody explain the difference between real, user, and sys? I understand that real is basically the time spent from start to finish (which can be affected by other processes), whereas user and sys consider the amount of time where the CPU was actually busy running a program (not waiting for other things like I/O). For example, what is the meaning of user and sys from this example? [1]:

        $ time wget https://download.virtualbox.org/virtualbox/6.1.28/virtualbox-6.1_6.1.28-147628~Ubuntu~eoan_amd64.deb
    
        real   0m8.515s
        user   0m0.125s
        sys    0m0.487s
    
    According to [2], user + sys would be a better measurement than real for comparing Python, Cython, and C++.

    [1] https://www.hostinger.com/tutorials/linux-time-command

    [2] https://stackoverflow.com/questions/10265162/the-meaning-of-...

  • That's a very interesting article, thanks. Interesting to note that Cython is only about twice as fast as Python 3.10 and only about 40% faster than Python 3.11.

    The official Python site advertises a speedup of 25% from 3.10 to 3.11; in the article a speedup of 60% was measured. It therefore usually makes sense to measure different algorithms. Unfortunately there is no Python or C++ implementation yet for https://github.com/smarr/are-we-fast-yet.