-
-
Notifications
You must be signed in to change notification settings - Fork 704
Open
Labels
Description
This question arose from ticket #30239, comment:36.
Should FiniteRankFreeModule and manifold objects always return a mutable copy, even for trivial operations? At least, this would be a consistent behavior.
As pointed out by Matthias, this already holds true for FreeModule:
sage: M = FreeModule(QQ, 3)
sage: v = M([1,2,3])
sage: w = v + 0
sage: w == v
True
sage: w is v
False
I feel quite torn about this, but slightly tend to the copy-version.
Addendum:
For FreeModule, we also have the following behavior:
sage: M = FreeModule(QQ, 3)
sage: M(0)
(0, 0, 0)
sage: M.zero()
(0, 0, 0)
sage: M.zero() is M(0)
False
I don't think that a parent should do that, especially when it already has a zero method. Should that be changed?
CC: @egourgoulhon @tscrim @mkoeppe
Component: misc
Branch/Commit: u/gh-mjungmath/return_copy_always_scalarfields @ b7b0b3f
Issue created by migration from https://trac.sagemath.org/ticket/30302