There are surely some people here who see directly in your code possibilities for performance gains, but it would be much easier if you
Do your best to make your example self-contained (“minimal working example”, MWE ), so that it runs (or gets to the error that you want help with) as is. This means including package loading (e.g. using ThatPackage ) and any data that the code operates on. If your data is large or proprietary, generate example data if possible and include that.