I am working on an inventory simulation model. I have this global list variable called current_batches
which consists of objects of a custom class Batch
and is used to keep track of the current inventory. While running the simulation, a number of functions use this current_batches
variable and modify it following certain events in the simulation.
Inside one function, I need to copy this variable and do some operations with the objects of the obtained copy, without modifying the objects of the original list. I used copy.deepcopy() and it works, but it is very slow and I will be running the simulation for many products with many iterations. Therefore, I was wondering if there is a way to copy this (global) list variable without using copy.deepcopy().
I briefly looked at the pickle module, but it was unclear to me whether this module was useful in my situation.