#11900: Serious regression caused by #9138
----------------------------------------------------------------------------------------+
   Reporter:  SimonKing                                                         
        |          Owner:  tbd                  
       Type:  defect                                                            
        |         Status:  needs_work           
   Priority:  critical                                                          
        |      Milestone:  sage-4.8             
  Component:  performance                                                       
        |       Keywords:  categories regression
Work_issues:  Laurent series rings are fields. Add docs. Don't use is_ring and 
friends  |       Upstream:  N/A                  
   Reviewer:  Jeroen Demeyer, Nicolas M. Thiéry                                 
        |         Author:  Simon King           
     Merged:                                                                    
        |   Dependencies:  #9138 #11911         
----------------------------------------------------------------------------------------+

Comment(by SimonKing):

 Replying to [comment:122 nthiery]:
 > I assume the wrong thing is that DeBruijnSequences subclasses
 EnumeratedSets, where the intention probably was to be a subcategory.

 Probably.

 Another possibility: `Category_singleton.__classcall__` should be a usual
 class method, but store the unique instance in an attribute (say, `_inst`)
 of the class - or, to be precise, in the dictionary of the class. Then, we
 could do something like
 {{{
 #!python
 class Category_singleton(Category):
     @staticmethod
     def __classcall__(object cls):
         try:
             return (<dict>cls.__dict__)['_inst']
         except KeyError:
             inst = Category.__classcall__(cls)
             cls._inst = inst
             return inst
 }}}

 Then, I get
 {{{
 sage: from sage.categories.category_singleton import Category_singleton
 sage: %timeit S=Category_singleton()
 625 loops, best of 3: 2.13 µs per loop
 sage: %timeit S=Singleton()
 625 loops, best of 3: 2.07 µs per loop
 }}}

 So, the timing seems ok, and it is subclassable:
 {{{
 sage: class Test(Singleton): pass
 ....:
 sage: Singleton()
 Category of singleton
 sage: Test()
 Category of test
 }}}

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