Opened 2 years ago
Last modified 5 months ago
#30302 new task
Always Return a Copy — at Version 2
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: |
Description (last modified by )
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?
Change History (2)
comment:1 Changed 2 years ago by
- Description modified (diff)
comment:2 Changed 2 years ago by
- Description modified (diff)
Note: See
TracTickets for help on using
tickets.