Exactly my experience. You can make Python code faster by profiling and improving the hotspots, but once you've done that it will still be 10x slower than C++/Rust at least, and that slowness is evenly spread through the whole program.
The number of use cases where you actually can move just a small part of the program to C++/Rust and that solves performance is actually really small. Basically highly numerical things like AI or SMT solving. Even supposedly IO bound things like Django tend to be quite slow in Python.
"""If you're looking for the next win, you don't have a hotspot. The CPU profile might look even-Stevens across the board. Let me give you a really simple example of this, I used to work on the [Edge] browser and you could find yourself with a significant regression one week and you're using way more CPU, and you look what the functions are and it's the same functions as always. It's layout and it's style computation, and that code hasn't changed a byte. It's the same excellent layout engine, it's the same excellent style engine, and yet the profiler will tell you you're spending way more time in layout. What's happened?
Somewhere in your code is a little whammy where someone invalidated a bunch of tree nodes which took about 8 nanoseconds and caused the layout engine to now do tons of computation that it didn't have to do before. No profiler in the world is going to save you from this problem, it's going to tell you that the problem is in the layout code. Well duh, thanks for that, of course the compute is in the layout code, it's always in the layout code, all we do is layout and draw. So I have to find the 3 nanoseconds where somebody invalidated something that they have no business invalidating because it's wrong. And the way you fix that is [to have a sense of how to check that you're invalidating the right thing, regression testing, visualizations, logging, planning] and it could be literally 4 or 5 instructions dirtying the cache and that's not going to show up in a profile.
[paraphrasing; Casey: if you've developed the whole browser without caring about this, at the end you're going to find it very slow and not be able to squeeze any more performance out of the layout engine? Rico: Right, this is not something you can fix at the finish line, it needs a plan]"""
That is just due to not using good performance observability tools. These sorts of problems are easy to see with a full instruction trace that uses good, standard visualization on a problem case.
A lot of lost performance also comes from things like the architectural decisions and technical debt that would pile up over time. These considerations are also like sand in that they're coarse, rough, irritating, and they get everywhere in the codebase.
Oh, and they can be annoying to refactor later on.
Using the right data structures for the right usage later on is like half the battle. People get really annoyed when you show them a Python program that is faster and shorter than someone's C# program, merely because they used the wrong data structures for how it's being used.
One of the nicest things of Java is that a list is a List<>. You can start with the default ArrayList or use a ton of other variants, or write your own, and all that changes is one line of code
One of my biggest beefs when moving Java -> C# back in 2004 was the paucity of collections in C#/.NET. There was C5, which was good, and the framework itself did eventually improve a little, but it was still no match for the Java standard library + Apache Commons Collections.
That and WinForms absolutely sucked compared to Swing. Layout options, tables/grids, and trees in particular were very poor in WinForms. Not to mention custom control development was far better in Swing than in WinForms. It was annoying because the one thing I’d expected to be better with .NET was the desktop UI framework.
The number of use cases where you actually can move just a small part of the program to C++/Rust and that solves performance is actually really small. Basically highly numerical things like AI or SMT solving. Even supposedly IO bound things like Django tend to be quite slow in Python.