Skip to content

copy/deepcopy for AccLattice #99

Description

@woodtp

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions