Python Forum
Understand order of magnitude performance gap between python and C++
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Understand order of magnitude performance gap between python and C++
#5
Thanks for all your inputs.

I also expected a 100x performance degradation at most. The current code is partially optimized using Numba, the original version took days to compute. The code is a simulation created by a physicist originally, so time is simulated in very small steps over the whole simulation function, which I know is not where python shines. Still, the code is fairly pythonic where it can be (heavy use of numpy build in functions and vectorization).

I did not have a go at pypy, but I did try Cython. The optimisation gain was similar to the one I got from Numba, still an order of magnitude less than what I would need.

Maybe the question could be more generally rephrased to: Is it possible for python to achieve similar (within 10x) performances than C++ for simulations with small time steps. And if so, what should one be aware of.

I profiled the code and identify the main functions responsible for the lack of performance. However I could not understand, yet, why these functions don't make use of the available CPU power despite parallelization and such.
Reply


Messages In This Thread
RE: Understand order of magnitude performance gap between python and C++ - by ThelannOryat - Mar-17-2021, 03:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Understand what it means that everything in Python is an object... bytecrunch 8 3,871 Mar-19-2021, 04:47 PM
Last Post: nilamo
  Trying to understand the python code spalisetty 2 1,906 Mar-16-2020, 08:11 AM
Last Post: javiertzr01
  I do not understand why my python looks different from tutorials. noodlespinbot 2 5,192 Oct-12-2019, 09:56 PM
Last Post: noodlespinbot
  performance kerzol81 1 1,942 Oct-07-2019, 10:19 AM
Last Post: buran
  I dont understand bytes in python. blackknite 3 4,071 Oct-02-2019, 07:39 PM
Last Post: Gribouillis
  Python performance rvkstudent 4 3,022 Apr-25-2019, 09:29 AM
Last Post: rvkstudent
  Python Turtle and order of implementation query Parsleigh 2 2,805 Mar-04-2019, 02:43 PM
Last Post: Parsleigh
  Trying to understand how import works in python patrick99e99 3 3,902 Jun-12-2018, 04:48 AM
Last Post: patrick99e99
  Python 3.6 dict key iteration order insearchofanswers87 7 5,407 May-22-2018, 05:33 PM
Last Post: snippsat
  Harmonics and their Magnitude values khanna 4 4,895 May-03-2018, 10:53 AM
Last Post: khanna

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020