sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.4k stars 473 forks source link

__copy__ methods for all classes that define "copy" methods (outside of sage.tensor, sage.manifolds) #32453

Open mkoeppe opened 3 years ago

mkoeppe commented 3 years ago

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.

For the same in sage.tensor, sage.manifolds, see #32476 instead.

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

CC: @tscrim @mjungmath @nbruin @kwankyu

Component: refactoring

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

kcrisman commented 3 years ago
comment:2

It seems this might be a long-awaited followup to #111?

mkoeppe commented 3 years ago

Description changed:

--- 
+++ 
@@ -1,4 +1,6 @@
 `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.
+
+For the same in `sage.tensor`, `sage.manifolds`, see #32476 instead.

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