Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mkoeppe opened this issue Sep 5, 2021 · 1 comment

Comments

@mkoeppe
Copy link
Contributor

mkoeppe commented Sep 5, 2021

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 https://docs.python.org/3/library/copy.html, 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()
            else:
                result._comp[ind] = val

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

CC: @tscrim @mjungmath @nbruin @kwankyu @kcrisman @egourgoulhon

Component: manifolds

Issue created by migration from https://trac.sagemath.org/ticket/32476

@mkoeppe mkoeppe added this to the sage-9.5 milestone Sep 5, 2021
@egourgoulhon
Copy link
Member

comment:1

Thanks for pointing this out!

@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 14, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 Mar 5, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Aug 31, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.8, sage-9.9 Jan 7, 2023
@mkoeppe mkoeppe removed this from the sage-10.0 milestone Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants