I mean, it's definitely both. Of course there can be algorithmic improvements, but a like-for-like rewrite of Python code into Rust can often be 10x faster.
Don't forget 10x iteration time and deploy time due to building on large projects. Still can be worth it, but I highly recommend build costs (CPU, RAM, Disk, Time) are considered in a rust rewrite decision. I'd even architect around it from the start as it can really add up.
Depends on the application. Tbh the comparison btwn python and rust is kind of dumb. But for the sake of argument - I don't think most well-written Python codebases can get 10x faster by using Rust. Bit faster ? sure maybe. Remember Python uses C under the hood. Unless there is a shit ton of looping or weird unrealistic conditions i don't think this is true
I think it totally depends, I’ve seen huge (100x) speed ups by moving a pure-python CPU heavy task to a compiled language. If you’re using something like numpy already to run compute natively, then yes it’s probably much more difficult to get gains.