#20743: Parent.list() should return an immutable tuple
-------------------------------------+------------------------
Reporter: jsrn | Owner:
Type: defect | Status: new
Priority: major | Milestone: sage-7.3
Component: categories | Resolution:
Keywords: parent, immutable | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
-------------------------------------+------------------------
Comment (by kedlaya):
Replying to [comment:12 nbruin]:
> Replying to [comment:10 kedlaya]:
>
> > But it might be unavoidable: tuples must consist of immutable objects,
so it may not always be possible to return one.
>
> That is not true:
> {{{
> sage: A=([1],[2])
> sage: A[0].append(3)
> sage: A
> ([1, 3], [2])
> }}}
>
Yes, you're right. The only time it matters whether a member of a tuple is
mutable is when the tuple is hashed.
So that means that one could cache a tuple and have `foo.list()` return a
list copy of that tuple, as long as there is no actual legitimate reason
to modify the cached list (I certainly can't think of one). In a
performance-critical situation, one shouldn't be asking for either a list
or a tuple anyway, but rather an iterator.
--
Ticket URL: <http://trac.sagemath.org/ticket/20743#comment:14>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.