I'm trying to improve the speed of an algorithm and, after looking at which operations are being called, I'm having difficulty pinning down exactly what's slowing things up. I'm wondering if Python's deepcopy() could possibly be the culprit or if I should look a little further into my own code.
What are you using deepcopy for? As the name suggests, deepcopy copies the object, and all subobjects recursively, so it is going to take an amount of time proportional to the size of the object you are copying. (with a bit of overhead to deal with circular references)
There isn't really any way to speed it up, if you are going to copy everything, you need to copy everything.
One question to ask, is do you need to copy everything, or can you just copy part of the structure.
What is the runtime complexity of Python's deepcopy()?