Opened 2 years ago

Last modified 5 months ago

#30302 new task

Always Return a Copy — at Initial Version

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

Status badges


This question arose from ticket #30239, comment:36.

Should FiniteRankFreeModule and manifold object 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
sage: w is v

I feel quite torn about this, but tend to the copy-version.


For FreeModule, we also have the following behavior:

sage: M = FreeModule(QQ, 3)
sage: M(0)
(0, 0, 0)
(0, 0, 0)
sage: is M(0)

I don't think that a parent should do that, especially when it already has a zero method. Should that be changed?

Change History (0)

Note: See TracTickets for help on using tickets.