At some point the game was spending more time on those things that on the physics simulation.
I have rewritten some code in C++ over time and parallelized as much as I can. However I'm starting to think that scripting languages are a false economy. There is no intrinsic reason you can't have a concise and easy to use language that can be quickly (in debug mode) compiled to the metal and dynamically linked to the project.
I might look at godot-rust at some point although It's a bit late considering the amount of code I have written already.