#12941: Cache should be cleared on cloning
----------------------------------------+-----------------------------------
       Reporter:  hivert                |         Owner:  hivert  
           Type:  defect                |        Status:  new     
       Priority:  major                 |     Milestone:  sage-5.1
      Component:  combinatorics         |    Resolution:          
       Keywords:  Clone, cache, days38  |   Work issues:          
Report Upstream:  N/A                   |     Reviewers:          
        Authors:  Florent Hivert        |     Merged in:          
   Dependencies:                        |      Stopgaps:          
----------------------------------------+-----------------------------------

Comment (by mjo):

 Replying to [comment:7 sdenton]:
 > mjo:
 > The idea of the cloneable array is that you make a clone, modify it, and
 then at the end of that modification the array should fit the parameters
 defined by the class, though it is itself a new object.  The array is only
 mutable during this cloning process; I think the f1[1]=100000 line should
 not be allowed, if my understanding is correct.
 [[BR]]

 Sorry, you're right. I botched my test. This does work:
 {{{
 sage: f = Foo(Parent(), [1,2,3])
 sage: f1 = f.clone()
 sage: f1[1] = 10000
 sage: f1
 [1, 10000, 3]
 }}}

 but doesn't do what I think it does. (I hit `up` a bunch of times, and
 apparently that's what I typed earlier when I should have done `with
 f.clone()...`)
 [[BR]][[BR]]

 > My understanding is that there's a push to switch from using the
 CombintaorialObject class to the ClonableArray class, which would make
 this cloning behavior a rather common occurrence.
 [[BR]]
 I still think the bug is in `Foo`. I could instead cache `sum()` in
 `self._cache`; would the superclass still be responsible for that?

 Another philosophical argument: `copy()` should make a copy.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12941#comment:8>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to