#13589: Controlling C3 to solve once for all the Method Resolution Order issues 
for
category classes
----------------------------------------------------------+-----------------
       Reporter:  nthiery                                 |         Owner:  
nthiery                   
           Type:  defect                                  |        Status:  
needs_review              
       Priority:  major                                   |     Milestone:  
sage-5.11                 
      Component:  categories                              |    Resolution:      
                      
       Keywords:  method resolution order, C3             |   Work issues:      
                      
Report Upstream:  N/A                                     |     Reviewers:  
Simon King, Florent Hivert
        Authors:  Nicolas M. ThiƩry                       |     Merged in:      
                      
   Dependencies:  #12894, #12876, #11935, #12895, #10193  |      Stopgaps:      
                      
----------------------------------------------------------+-----------------

Comment (by SimonKing):

 In the computation of _cmp_key, it says:
 {{{
     atoms = ("FacadeSets", "Finite", "Infinite", "EnumeratedSets",
 "FiniteDimensionalModulesWithBasis", "GradedModules", "ModulesWithBasis",
 "AdditiveMagmas", "Magmas", "Semigroups", "Monoids",
 "FinitePermutationGroups", "Rngs", "Domains")
     classname = self.__class__.__name__
     flag = 0
     for i, axiom in enumerate(atoms):
         if classname.startswith(axiom):
             flag = flag | (1 << i)
 }}}

 First a Python question: Will the tuple `atoms` be constructed repeatedly
 in this method? If this is the case, it might be better to move it to
 module level.

 Second question: With the exception of "Finite" and
 "FiniteDimensionalModulesWithBases", the atoms are pairwise incompatible,
 in the sense of "if classname starts with one of the atoms, then it will
 certainly not start with any other atom". Hence, it seems possible to
 rewrite it such that the `for` loop is quit after the first case in which
 the `if` clause is true.

 But again, probably a speed gain in a method that is called only once will
 be negligible.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13589#comment:56>
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 http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to