Cached permutation groups

බැලීම් 2
පළමු නොකියවූ පණිවිඩය දක්වා මඟ හරින්න

Rob Beezer

නොකියවූ,
2010 ජූනි 5, 23.49.402010-06-05
සිට sage-devel
Consider

sage: G = SymmetricGroup(2)
sage: elements = G.list()
sage: elements.remove(G("()"))
sage: K = SymmetricGroup(2)
sage: K.list()
[(1,2)]

Notice K lacks the identity permutation. I'd at least expect K to
be a "new" undisturbed version of S_2.

Is there some overly-aggressive caching here? Should there be some
protection against the above? Or am I missing something?

Using elements = copy(G.list()) causes K to have all of its
elements, but the docstring for list() doesn't say anything about
making a copy, or being an "in-place" version, etc.

Rob

Robert Bradshaw

නොකියවූ,
2010 ජූනි 6, 00.35.392010-06-06
සිට sage-...@googlegroups.com

Yes, it's a cached_method returning a mutable object, which is bad.
This is a case where we would be better of return a tuple, and letting
the user create a list out of it if they wanted.

http://trac.sagemath.org/sage_trac/ticket/9155

- Robert


Rob Beezer

නොකියවූ,
2010 ජූනි 6, 00.56.212010-06-06
සිට sage-devel
Robert,

Thanks for the confirmation - I figured that was one of the
possibilities.

Rob

On Jun 5, 9:35 pm, Robert Bradshaw <rober...@math.washington.edu>
wrote:
සියල්ලට පිළිතුරු දෙන්න
කර්තෘට පිළිතුරු දෙන්න
ඉදිරියට යවන්න
නව පණිවිඩ 0