Opened 11 months ago

Last modified 5 months ago

#32476 new enhancement

sage.tensor, sage.manifolds: __copy__, __deepcopy__ methods for all classes that define "copy" methods

Reported by: mkoeppe Owned by:
Priority: major Milestone: sage-9.7
Component: manifolds Keywords:
Cc: tscrim, gh-mjungmath, nbruin, klee, kcrisman, egourgoulhon Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges


git grep 'def copy' reveals a number of classes that define ad-hoc copy methods but not __copy__ methods. Hence, they do not implement the copy protocol, so copy.copy will resort to pickling/unpickling for making a copy.

Components.copy, for example, implements an ad-hoc version of a deepcopy of sorts:

        for ind, val in self._comp.items():
            if isinstance(val, SageObject) and hasattr(val, 'copy'):
                result._comp[ind] = val.copy()
                result._comp[ind] = val

For classes whose instances are immutable, see #13811 instead.

Change History (3)

comment:1 Changed 11 months ago by egourgoulhon

Thanks for pointing this out!

comment:2 Changed 8 months ago by mkoeppe

  • Milestone changed from sage-9.5 to sage-9.6

comment:3 Changed 5 months ago by mkoeppe

  • Milestone changed from sage-9.6 to sage-9.7
Note: See TracTickets for help on using tickets.