#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:15 nbruin]:
> Replying to [comment:14 kedlaya]:
> > 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.
>
> No, an iterator provides a different kind of interface: if you need
indexing an iterator will just not do. Even for iteration an iterator
might not be the lowest overhead: you're incurring python call overhead on
each access. List/tuple items can be retrieved more efficiently than that
(provided the entries have to be in memory anyway). This will be a tiny
difference, though.
If the cached thing ends up being a tuple, then there's no reason not to
implement `foo.tuple()` returning a reference to the cached tuple. If
there is a genuine concern that this is "not discoverable" (which I'm not
sure there is for users that know the difference between a list and a
tuple), we can modify the docstring for `foo.list()` to say `SEEALSO:
foo.tuple()`.
--
Ticket URL: <http://trac.sagemath.org/ticket/20743#comment:16>
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.