#715: Parents probably not reclaimed due to too much caching
-------------------------------------------------+--------------------------
   Reporter:  robertwb                           |          Owner:  somebody    
       
       Type:  defect                             |         Status:  needs_work  
       
   Priority:  major                              |      Milestone:  sage-4.8    
       
  Component:  coercion                           |       Keywords:  weak cache 
coercion
Work_issues:  Comparison of the third key items  |       Upstream:  N/A         
       
   Reviewer:                                     |         Author:  Simon King  
       
     Merged:                                     |   Dependencies:  #9138, 
#11900      
-------------------------------------------------+--------------------------

Comment(by SimonKing):

 It really is not an easy question whether or not we should have "is" or
 "==".

 On the one hand, we have the lines
 {{{
 !python
             if y_mor is not None:
                 all.append("Coercion on right operand via")
                 all.append(y_mor)
                 if res is not None and res is not y_mor.codomain():
                     raise RuntimeError, ("BUG in coercion model: codomains
 not equal!", x_mor, y_mor)
 }}}
 in sage/structure/coerce.pyx seem to imply that comparison via "is" is the
 right thing to do.

 But in the same file, the coercion model copes with the fact that some
 parents are not unique:
 {{{
 !python
         # Make sure the domains are correct
         if R_map.domain() is not R:
             if fix:
                 connecting = R_map.domain().coerce_map_from(R)
                 if connecting is not None:
                     R_map = R_map * connecting
             if R_map.domain() is not R:
                 raise RuntimeError, ("BUG in coercion model, left domain
 must be original parent", R, R_map)
         if S_map is not None and S_map.domain() is not S:
             if fix:
                 connecting = S_map.domain().coerce_map_from(S)
                 if connecting is not None:
                     S_map = S_map * connecting
             if S_map.domain() is not S:
                 raise RuntimeError, ("BUG in coercion model, right domain
 must be original parent", S, S_map)
 }}}
 That would suggest that comparison by "==" (the old behaviour or
 `TripleDict`) is fine.

 Perhaps we should actually have to variants of `TripleDict`, one using
 "is" and one using "==".

 Note another detail of sage/structure/coerce.pyx: We have
 {{{
     cpdef verify_action(self, action, R, S, op, bint fix=True):
 }}}
 but
 {{{
     cpdef verify_coercion_maps(self, R, S, homs, bint fix=False):
 }}}
 Note the different default value for "fix". If "fix" is True then the
 coercion model tries to cope with non-unique parents by prepending a
 conversion between the two equal copies of a parent.

 Since the default is to fix non-unique parents for actions, but not for
 coercion maps, I suggest that a "=="-`TripleDict` should be used for
 actions and an "is"-`TripleDict` for coercions.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/715#comment:35>
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