Think of ways to implement shallow and deep copying of PyORBIT objects. By default, deepcopy attempts to serialize/pickle object instance, which fails due to the inability to extract the state of the underlying C++ objects.
Solution 1: If we manually override __copy__ and __deepcopy__ methods, can we bypass serialization altogether? We would need to override these methods in a lot of places, potentially, unless we find a generic way to accomplish that.
Solution 2: C extension to implement the methods necessary to make pickling possible: https://docs.python.org/3/library/pickle.html#object.__reduce__.
Per @shishlo, the lattice XML string could be saved member variable to facilitate construction of an identical AccLattice. How to handle space charge nodes and other complications?
Think of ways to implement shallow and deep copying of PyORBIT objects. By default,
deepcopyattempts to serialize/pickle object instance, which fails due to the inability to extract the state of the underlying C++ objects.Solution 1: If we manually override
__copy__and__deepcopy__methods, can we bypass serialization altogether? We would need to override these methods in a lot of places, potentially, unless we find a generic way to accomplish that.Solution 2: C extension to implement the methods necessary to make pickling possible: https://docs.python.org/3/library/pickle.html#object.__reduce__.
Per @shishlo, the lattice XML string could be saved member variable to facilitate construction of an identical
AccLattice. How to handle space charge nodes and other complications?