How do I debug parts of code efficiently that are called towards the end of a compute intensive program?

I am looking for ways to debug code at the end of my program without having to run through all the code before the part of code in question for each debugging.

Maybe a little context: I am using a bunch of heuristics to solve vehicle routing problems. During which, complex objects like routes and vehicles are created. However, as is the crux with VRP, code run times are a few minutes, and are even slower in debug mode (IDE is PyCharm Pro).

Now, if I want to debug code that takes those complex objects as an input, I have to run the whole code every time I am running the debugger. Until it reaches the break point, it takes quite a while. The work-around I am using at the moment is to debug not with the full input data but with just a small sub-sample to have less run time. However, I actually would like to debug on the original, full data.

Is there maybe some way to save the variable states just before the part of the code that I want to debug so that every time I am running the debugger it doesn't have to start from scratch but can just load the variables and go on from there? (I am only making changes down the road from this imaginary "variable recovery point".)

Any other tips and tricks on how to efficiently debug such stuff?

Please sign in to leave a comment.